forums › forums › SQLyog › Using SQLyog › Automatic Default Values For "not Null" Fields?
- This topic is empty.
-
AuthorPosts
-
-
December 12, 2011 at 6:52 am #32921
Chirantan Thakkar
MemberHi,
please refer: http://dev.mysql.com/doc/refman/5.0/en/data-type-defaults.html
Quote:If the column cannot take NULL as the value, MySQL defines the column with an explicit DEFAULT clause, using the implicit default value for the column data typePrior to MySQL 5.0.2, if a column definition includes no explicit DEFAULT value and the “Not Null” is ticked, then mysql will automatically assign default value to the column based on datatype. So, we can not control it.
By creating a unique index on each column, You can assure a unique value in each column. This will accept NULL for the first time for the column but not again for the same column(ie, MySQL will give you error except for the first time you insert NULL). But again, that will not accept any duplicate value.
-
December 12, 2011 at 8:24 am #32922
peterlaursen
ParticipantIt also depends on the sql_mode with servers > 5.02. Now default is applied in 'strict' modes. But you will then get an error if not specifying a value yourself.
You can definde strict mode ('strict_all_tables') for the connection in the 'advanced' tab of SQLyog connection manager. Same page in the MySQL documentation explains:
Quote:“MySQL handles the column according to the SQL mode in effect at the time: If strict SQL mode is not enabled, MySQL sets the column to the implicit default value for the column data type. If strict mode is enabled, an error occurs for transactional tables and the statement is rolled back. For nontransactional tables, an error occurs, but if this happens for the second or subsequent row of a multiple-row statement, the preceding rows will have been inserted.” -
December 13, 2011 at 9:15 am #32923
kybert
MemberThanks for the reply. Strict mode shows no setting in the setting viewer.
I installed mysql 5.1.60 and it has fixed the problem.
-
-
AuthorPosts
- You must be logged in to reply to this topic.