我有一个事务表,我的问题是跟踪该transactionDateTime
列。使用 SQL,我似乎无法获取DATE
或TIMESTAMP
格式化,因此任何插入的数据都必须在任何一天的上午 8 点到晚上 10 点之间:
CREATE TABLE Transaction_T
(transactionID NUMBER(8,0) ,
employeeID NUMBER(10,0) NOT NULL,
customerID NUMBER(6,0) NOT NULL,
transactionDate VARCHAR2(9) NOT NULL,
transactionPayment VARCHAR2(10) check(transactionPayment IN('cash','credit','debit','ebt')),
transactionType VARCHAR2(10) check(transactionType IN('void','return','sale')),
transactionDateTime TIMESTAMP check(transactionDateTime < '% 22:00:00' AND transactionDateTime > '% 08:00:00') NOT NULL,
CONSTRAINT TransactionPK PRIMARY KEY (transactionID),
CONSTRAINT TransactionFK1 FOREIGN KEY (employeeID) REFERENCES Employee_T(employeeID),
CONSTRAINT TranscationFK2 FOREIGN KEY (customerID) REFERENCES Customer_T(customerID));
上表已创建,但在尝试插入正确的 时Date(Time)
,我收到有关 1 到 12 小时之间的格式错误,或者当时间低于 12 时,我收到了无效月份。我使用了 Oracle 文档格式,但仍然没有运气:
INSERT INTO
transaction_T(transactionID, employeeID, customerID, transactionDate, transactionPayment, transactionType, transactionDateTime)
VALUES(00000001, 0001, 000004, '04-APR-13','ebt','sale','04-APR-13 13:25:10');