Mega Code Archive

 
Categories / MySQL / Key
 

Define and use primary key

/* mysql> Drop table Attributes; mysql> CREATE TABLE Attributes     -> (     ->    ID SMALLINT NOT NULL PRIMARY KEY,     ->    Settings TINYINT UNSIGNED NOT NULL     -> ); Query OK, 0 rows affected (0.06 sec) mysql> INSERT INTO Attributes VALUES (101, 58),     ->                               (102, 73),     ->                               (103, 45); Query OK, 3 rows affected (0.00 sec) Records: 3  Duplicates: 0  Warnings: 0 mysql> select * from Attributes; +-----+----------+ | ID  | Settings | +-----+----------+ | 101 |       58 | | 102 |       73 | | 103 |       45 | +-----+----------+ 3 rows in set (0.00 sec) */ Drop table Attributes; CREATE TABLE Attributes (    ID SMALLINT NOT NULL PRIMARY KEY,    Settings TINYINT UNSIGNED NOT NULL ); INSERT INTO Attributes VALUES (101, 58),                                (102, 73),                                (103, 45); select * from Attributes;