0
我發現了一個例子SQL建立時間漁政船,我從這個鏈接https://gist.github.com/johngrimes/408559如何在netezza中創建時間維度?
一切都在mysql的完美搞定,
但是,當我試圖在Netezza公司,代碼無法正常工作,有些錯誤是出現諸如 「期待USING' or
')' '或'', ''」 等
我曾試圖修改
CREATE TABLE numbers_small (number INT);
INSERT INTO numbers_small VALUES (0);
INSERT INTO numbers_small VALUES (1);
INSERT INTO numbers_small VALUES (2);
INSERT INTO numbers_small VALUES (3);
INSERT INTO numbers_small VALUES (4);
INSERT INTO numbers_small VALUES (5);
INSERT INTO numbers_small VALUES (6);
INSERT INTO numbers_small VALUES (7);
INSERT INTO numbers_small VALUES (8);
INSERT INTO numbers_small VALUES (9);
CREATE TABLE numbers (number BIGINT);
INSERT INTO numbers
SELECT thousands.number * 1000 + hundreds.number * 100 + tens.number * 10 + ones.number
FROM numbers_small thousands, numbers_small hundreds, numbers_small tens, numbers_small ones
LIMIT 1000000;
CREATE TABLE D_TIME_DAILY_TES (
TIME_ID BIGINT PRIMARY KEY,
TANGGAL DATE NOT NULL,
TAHUN INT NOT NULL,
BULAN CHAR(10) NOT NULL,
HARI CHAR(10) NOT NULL,
LAST_UPDATE timestamp NOT NULL,
constraint D_TIME_DAILY_TES UNIQUE KEY (TANGGAL)
);
INSERT INTO D_TIME_DAILY_TES (TIME_ID, TANGGAL, LAST_UPDATE)
SELECT number, DATE_ADD('2010-01-01', INTERVAL number DAY), CURRENT_TIMESTAMP
FROM numbers
WHERE DATE_ADD('2010-01-01', INTERVAL number DAY) BETWEEN '2014-01-01' AND '2014-12-31'
ORDER BY number;
UPDATE D_TIME_DAILY_TES SET
HARI = DATE_FORMAT(TANGGAL, "%W"),
BULAN = DATE_FORMAT(TANGGAL, "%M"),
TAHUN = DATE_FORMAT(TANGGAL, "%Y"),
LAST_UPDATE = CURRENT_TIMESTAMP;
,但它仍然沒有工作:(
我該如何解決它?
thx :)