Mega Code Archive

 
Categories / MySQL / Insert Delete Update
 

Column list in the insert statement

mysql> mysql> CREATE TABLE towels     -> (     ->   code   VARCHAR(8)      NOT NULL PRIMARY KEY,     ->   name   VARCHAR(20)     NOT NULL,     ->   color VARCHAR(20)      DEFAULT "White"     -> ); Query OK, 0 rows affected (0.00 sec) mysql> mysql> INSERT INTO towels ( code, name, color ) VALUES ( "821/7355", "Dolphin", "Blue" ); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO towels ( color, code, name )VALUES ( "Lilac", "830/1921", "Daisy" ); Query OK, 1 row affected (0.00 sec) mysql> INSERT INTO towels ( code, name ) VALUES ( "830/2078", "Starburst" ); Query OK, 1 row affected (0.00 sec) mysql> mysql> SELECT * FROM towels; +----------+-----------+-------+ | code     | name      | color | +----------+-----------+-------+ | 821/7355 | Dolphin   | Blue  | | 830/1921 | Daisy     | Lilac | | 830/2078 | Starburst | White | +----------+-----------+-------+ 3 rows in set (0.00 sec) mysql> mysql> drop table towels; Query OK, 0 rows affected (0.00 sec)