List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:June 27 2008 6:04pm
Subject:Re: How to ensure column expression gets stored as Double and not
Decimal
View as plain text  
In the last episode (Jun 27), mos said:
> I'm creating a MyISAM table using a Select statement as in:
> 
> create table t2 select if(col1>col2,1.2,4.1) NewCol from t1
> 
> (Ok, the computations are a lot more complicated than that).
> 
> For some reason the column type of NewCol is Decimal and not Double.
> How do I force the expression column to be double? I have about a
> dozen columns all set to Decimal because they are expressions and I'd
> rather they all be double.  I don't want to have to do an Alter Table
> after the table is created. Any ideas?

Add a create_definition clause to your CREATE TABLE statement just as
if you were creating a blank table.  That way, you can force whatever
field types you want.

http://dev.mysql.com/doc/refman/5.0/en/create-table.html

  CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
    [(create_definition,...)]
    [table_option] ...
    select_statement



-- 
	Dan Nelson
	dnelson@stripped
Thread
How to ensure column expression gets stored as Double and notDecimalmos27 Jun
  • Re: How to ensure column expression gets stored as Double and notDecimalDan Nelson27 Jun