Lab 10 DB
Lab 10 DB
Lab 10 DB
OBJECTIVES:
• Create Index Statement
• Drop Index
• Auto Increment Field
The SQL statement below creates an index named "idx_lastname" on the "LastName" column in the "Persons"
table:
CREATE INDEX idx_lastname
ON Persons (Last Name);
If you want to create an index on a combination of columns, you can list the column names within the
parentheses, separated by commas:
SQL Server:
DROP INDEX table_name.index_name;
My SQL:
ALTER TABLE table_name
DROP INDEX index_name;
Auto-increment allows a unique number to be generated automatically when a new record is inserted into a
table.
Often this is the primary key field that we would like to be created automatically every time a new record is
inserted.
To insert a new record into the "Persons" table, we will NOT have to specify a value for the "Person id"
column (a unique value will be added automatically):
The SQL statement above would insert a new record into the "Persons" table. The "Person id" column would
be assigned a unique value. The "First Name" column would be set to "Lars" and the "Last Name" column
would be set to "Monsen".