Use the DEFAULT in the insert statement : Insert : Insert Update Delete MySQL TUTORIALS


MySQL TUTORIALS » Insert Update Delete » Insert »

 

Use the DEFAULT in the insert statement


mysql>
mysql> CREATE TABLE myTable(
    ->    ID TINYINT UNSIGNED NOT NULL DEFAULT 1,
    ->    Name VARCHAR(50NOT NULL
    -> );
Query OK, rows affected (0.03 sec)

mysql>
mysql>
mysql> INSERT INTO myTable (ID, Name)VALUES (1,'A'),(DEFAULT,'B');
Query OK, rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql>
mysql> select from myTable;
+----+------+
| ID | Name |
+----+------+
|  | A    |
|  | B    |
+----+------+
rows in set (0.00 sec)

mysql>
mysql> drop table myTable;
Query OK, rows affected (0.01 sec)

mysql>



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo Insert Update Delete
» Insert