mySQL and defaults

Bob Sneidar bobs at twft.com
Thu Mar 17 15:00:41 EDT 2011


Oh thanks Warren! That will work famously! Unfortunately I just finished the code that strips all the DEFAULT parameters from all text column definitions LOL! I guess it's back to work undoing my last undo. Still, nice to know it can be done. 

Bob


On Mar 17, 2011, at 10:51 AM, Warren Samples wrote:

> 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
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list