2014-09-23 51 views
0

我所做的只是重拍表和列添加空constrants和默認值:非常簡單插入從選擇不工作?

原始表結構(現更名):

CREATE TABLE "CARTWEIGHTS_old" (
    EntryTime DateTime, 
    Employee TEXT, 
    PLUGS NUMERIC, 
    ID INTEGER PRIMARY KEY, 
    PO NUMERIC, 
    FUSER INTEGER, 
    REMAN INTEGER, 
    OEM INTEGER, 
    DIGITEK INTEGER, 
    LEXMARK INTEGER, 
    PDW INTEGER, 
    TRASH INTEGER, 
    CART TEXT, 
    "Voided" BOOL NOT NULL DEFAULT 0 
) 

新表:

CREATE TABLE CARTWEIGHTS (
    EntryTime DateTime, 
    Employee TEXT, 
    PLUGS NUMERIC NOT NULL DEFAULT 0, 
    ID INTEGER PRIMARY KEY, 
    PO NUMERIC, 
    FUSER INTEGER NOT NULL DEFAULT 0, 
    REMAN INTEGER NOT NULL DEFAULT 0, 
    OEM INTEGER NOT NULL DEFAULT 0, 
    DIGITEK INTEGER NOT NULL DEFAULT 0, 
    LEXMARK INTEGER NOT NULL DEFAULT 0, 
    PDW INTEGER NOT NULL DEFAULT 0, 
    TRASH INTEGER NOT NULL DEFAULT 0, 
    CART TEXT, 
    "Voided" BOOL NOT NULL DEFAULT 0 
) 

然後當我嘗試運行時:

insert into CARTWEIGHTS 
select * from CARTWEIGHTS_old 

CARTWEI GHTS表格未隨信息更新。 SQLite也不會給我任何錯誤。

+0

什麼select * from CARTWEIGHTS_old returns? – AndreDuarte 2014-09-23 13:03:57

+0

@AndreDuarte它返回所期望的數據,表中的所有數據...... – user2125348 2014-09-23 13:05:21

+1

SQLite是否支持這種類型的操作?奇怪的是,它沒有返回任何錯誤... – AndreDuarte 2014-09-23 13:08:35

回答

2

你的問題是與ID序列發生器。嘗試不要將您的PK插入目標表中:

INSERT INTO "CARTWEIGHTS" 
"EntryTime","Employee","PLUGS","PO","FUSER","REMAN","OEM","DIGITEK","LEXMARK", 
"P‌​DW","TRASH","CART","Voided" 
SELECT "EntryTime","Employee","PLUGS","PO","FUSER","REMAN","OEM","DIGITEK","LEXMARK", 
"P‌​DW","TRASH","CART","Voided" FROM "CARTWEIGHTS_old"