How To Create A Key Field

Table of contents:

How To Create A Key Field
How To Create A Key Field

Video: How To Create A Key Field

Video: How To Create A Key Field
Video: Creating Your Own QuickBase Key Field 2024, December
Anonim

The "key field" in the database table is the field of the table for which the management system of this database creates additional service records that serve to speed up the search for rows. The procedure of re-sorting according to the contents of a key field, which the DBMS performs after each change in a table, is called indexing by a key field. In MySQL DBMS, it is convenient to use the phpMyAdmin application to create key fields.

How to create a key field
How to create a key field

Instructions

Step 1

Log in to phpMyAdmin and go to the database containing the table you are interested in by clicking on the corresponding link in the left pane of the application interface. In the left pane of the page that opens, there will be a list of tables that exist in the selected database, and in the right pane there will be a table with more detailed information about them. You need to click either on the link with the name of the required table in the left frame, or on the "Structure" icon in the corresponding line in the right frame. As a result, the list of fields of this table will be loaded into the right frame.

Step 2

If you need to make a key one of the existing fields, then you have several options. If you need to create a key only to speed up the search for records (there can be several such keys in the table at the same time), then click on the “Index” icon in the “Action” column of the required table field. The application will compose the required SQL query and send it to the server. If it should be a unique key, by which the table records are sorted by default (there can be only one and it is called the “primary index”), then click on the “Primary” icon in the same “Action” column.

Step 3

If you need to make a key field that is not yet in the table, then check the box "At the beginning of the table" and click the "OK" button in the same line. In the form that opens, fill in the fields with the parameters of the field being created and put a check in the line with the "Primary" icon, and then click the "Save" button and the application will generate and send the required SQL query.

Step 4

You can also form the required request yourself. To do this, click on the SQL link and type the required query text in the multi-line text field. For example, it can look like this:

ALTER TABLE `tableOne` DROP PRIMARY KEY, ADD PRIMARY KEY (` login`)

This query overrides the existing primary key in the table called tableOne and assigns the field named login as the primary key. To send the request, click the "OK" button.

Recommended: