how to avoid the type of field not be changed with create table as select command in sqlite3? -
i found data type of field changed when use command such create table select * ;
c:\users\root>sqlite3 g:\\test.db sqlite version 3.8.3.1 2014-02-11 14:52:19 enter ".help" instructions enter sql statements terminated ";" sqlite> create table test1 (day datetime); sqlite> insert test1 (day) values(20101001); sqlite> pragma table_info(test1); 0|day|datetime|0||0 sqlite> create table test2 select * test1; sqlite> pragma table_info(test2); 0|day|num|0||0
the field day datetime type in test1,when use command
create table test2 select * test1;
the field day type in test2 changed num type.
how can make field day not changed ?how fix ?
create table test2 select * test1;
the documentation says:
the declared type of each column determined expression affinity of corresponding expression in result set of select statement
in other words, data types of original table not copied (in same way constraints, default values, or collations not copied).
it not possible duplicate table's schema create table ... as. that, have execute original table's create table statement.
Comments
Post a Comment