mySQL and defaults

Warren Samples warren at warrensweb.us
Thu Mar 17 13:51:41 EDT 2011


On Thursday, March 17, 2011 12:18:19 PM Bob Sneidar wrote:
> From the MySQL reference manual on TEXT types:
> 
> 
>          In most respects, you can regard a BLOB column as a VARBINARY
> column that can be as large as you like. Similarly, you can regard a TEXT
> column as a VARCHAR column. BLOB and TEXT differ from VARBINARY and
> VARCHAR in the following ways:
> 
> 	<snip>
> 
> 	•  BLOB and TEXT columns cannot have DEFAULT values.
> 
> 
> The last line would lead you to believe that CHAR and VARCHAR types CAN
> have default values, but nay. This produces a syntax error. Any way around
> this?
> 
> Bob


Bob,

Did you try setting 'NOT NULL' before "DEFAULT' ?

Here's an example found on the internet:

mysql> CREATE TABLE myTable
    -> (
    ->    ID SMALLINT UNSIGNED NOT NULL,
    ->    City VARCHAR(40) NOT NULL DEFAULT 'Unknown'
    -> );
Query OK, 0 rows affected (0.05 sec)

mysql>
mysql> desc myTable;
+-------+----------------------+------+-----+---------+-------+
| Field | Type                 | Null | Key | Default | Extra |
+-------+----------------------+------+-----+---------+-------+
| ID    | smallint(5) unsigned | NO   |     |         |       |
| City  | varchar(40)          | NO   |     | Unknown |       |
+-------+----------------------+------+-----+---------+-------+
2 rows in set (0.01 sec)

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

mysql>

Does it work for you?

Good Luck!

Warren




More information about the use-livecode mailing list