Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Omit Columns with Default Values in INSERT Statement
How To Omit Columns with Default Values in INSERT Statement? - MySQL FAQs - Understanding SQL INSERT, UPDATE and DELETE Statements
✍: FYIcenter.com
If you don't want to specify values for columns that have default values, or you want to specify values to columns in an order different than how they are defined, you can provide a column list in the INSERT statement. If a column is omitted in the column, MySQL applies 3 rules:
The following tutorial exercise gives you some good examples:
mysql> INSERT INTO fyi_links (url, id)
VALUES ('sqa.fyicenter.com', 103);
Query OK, 1 row affected, 1 warning (0.01 sec)
mysql> INSERT INTO fyi_links (id) VALUES (110);
Query OK, 1 row affected, 1 warning (0.06 sec)
mysql> INSERT INTO fyi_links (url)
VALUES ('www.fyicenter.com');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> SELECT id, url, notes, counts, DATE(created)
FROM fyi_links;
+-----+-------------------+-------+--------+---------------+
| id | url | notes | counts | DATE(created) |
+-----+-------------------+-------+--------+---------------+
| 101 | dev.fyicenter.com | NULL | 0 | 2006-04-30 |
| 102 | dba.fyicenter.com | NULL | 0 | 2006-07-01 |
| 103 | sqa.fyicenter.com | NULL | NULL | 2006-07-01 |
| 110 | | NULL | NULL | 2006-07-01 |
| 0 | www.fyicenter.com | NULL | NULL | 2006-07-01 |
+-----+-------------------+-------+--------+---------------+
5 rows in set (0.00 sec)
2007-05-11, 5680👍, 0💬
Popular Posts:
What is the significance of Finalize method in .NET? .NET Garbage collector does almost all clean up...
What are database triggers? How are the triggers fired? Read this collection of questions and answer...
How To Recover a Dropped Index? - Oracle DBA FAQ - Managing Oracle Table Indexes If you have the rec...
What does a well-written Object Oriented program look like? A well-written object oriented program e...
What are shared (VB.NET)/Static(C#) variables? Static/Shared classes are used when a class provides ...