MySQL default values on INSERT

When inserting into regular database systems, like Oracle, DB2, and even PostgreSQL, the omitted attributes from an INSERT are automatically set to default. Not so with MyISAM tables on MySQL. The syntax required by MySQL for an implicit default when multiple attributes are inserted is DEFAULT. For example:

INSERT INTO my_table VALUES (?,?,DEFAULT,?,DEFAULT)

will set the third and fifth parameters to default values.

Note that this has been only tested with the JDBC driver, and other database drivers might behave differently.

References:

This entry was posted in Linux and tagged . Bookmark the permalink.

NewPush has solutions to fit your business needs.  For more than a decade, our focus has been to take on the technical challenges that are the hardest and most time-consumming.  Our goal is to free up your resources to focus on the core activities of your business and to drive your business performance.  Please visit our main site at newpush.com for more information or call us at +1-303-423-4500.