Tutorial by Examples

-- Create an index for column 'name' in table 'my_table' CREATE INDEX idx_name ON my_table(name);
A unique index prevents the insertion of duplicated data in a table. NULL values can be inserted in the columns that form part of the unique index (since, by definition, a NULL value is different from any other value, including another NULL value) -- Creates a unique index for column 'name' in tabl...
-- Drop an index for column 'name' in table 'my_table' DROP INDEX idx_name ON my_table;
This will create a composite index of both keys, mystring and mydatetime and speed up queries with both columns in the WHERE clause. CREATE INDEX idx_mycol_myothercol ON my_table(mycol, myothercol) Note: The order is important! If the search query does not include both columns in the WHERE claus...
CREATE TABLE ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, ... PRIMARY KEY(id), ... ); Main notes: Starts with 1 and increments by 1 automatically when you fail to specify it on INSERT, or specify it as NULL. The ids are always distinct from each other, but... Do not make a...

Page 1 of 1