Hi, > Why does MySQL accept this insert statement with a warning? > > Insert into Sessions (id) values (20de8376640263673ea03938); > > Query OK, 1 row affected. > > I expected a warning because of the Token column shouldn't be NULL! > > I have a table with three columns: > > Id # int not null > Token # char (1) not null > SessTime # Timestamp
Welcome to the wonderful world of MySQL ;-) Read this: http://dev.mysql.com/doc/mysql/en/CREATE_TABLE.html " DEFAULT value must be a constant; it cannot be a function or an expression. If no DEFAULT value is specified for a column, MySQL automatically assigns one, as follows. If the column can take NULL as a value, the default value is NULL. If the column is declared as NOT NULL, the default value depends on the column type: a.. For numeric types other than those declared with the AUTO_INCREMENT attribute, the default is 0. For an AUTO_INCREMENT column, the default value is the next value in the sequence. b.. For date and time types other than TIMESTAMP, the default is the appropriate ``zero'' value for the type. For the first TIMESTAMP column in a table, the default value is the current date and time. See section 12.5 Date and Time Types. c.. For string types other than ENUM, the default value is the empty string. For ENUM, the default is the first enumeration value. " With regards, Martijn Tonies Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL Server. Upscene Productions http://www.upscene.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]