P Kishor wrote: > SQLite version 3.6.11 > Enter ".help" for instructions > Enter SQL statements terminated with a ";" > sqlite> CREATE TABLE foo (id INTEGER PRIMARY KEY, desc TEXT, num > INTEGER DEFAULT 0); > sqlite> INSERT INTO foo (desc) VALUES ('foo'); > sqlite> INSERT INTO foo (desc) VALUES ('bar'); > sqlite> INSERT INTO foo (desc) VALUES ('baz'); > sqlite> SELECT * FROM foo; > id desc num > ---------- ---------- ---------- > 1 foo 0 > 2 bar 0 > 3 baz 0 > sqlite> CREATE TABLE bar AS SELECT * FROM foo; > sqlite> .s > CREATE TABLE bar(id INTEGER,"desc" TEXT,num INTEGER); > CREATE TABLE foo (id INTEGER PRIMARY KEY, desc TEXT, num INTEGER > DEFAULT 0); > > > Why did the definition of the column num change? Where did the > DEFAULT 0 part go in the definition of num?
You don't make a copy of a table - you make a copy of the resultset of a SELECT statement. Columns in said resultset don't carry attributes like DEFAULT, even though columns in the underlying table may. Consider: create table bar as select id + 1, desc || 'xyz', num * id from foo; What do you expect the definition of bar to be? Igor Tandetnik
_______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users