嗨,我是 Oracle 的新手,忘记了如何输入日期。我尝试了很多变体,但似乎无法得到它,而且我在互联网上查看过,但找不到正确的示例。我的表是这样设置的:hiredate DATE,(DATE 是我假设的默认输入,但默认是什么)。
谢谢你的帮助。
这是我的代码:
SQL> SET LINESIZE 120
SQL> SET PAGESIZE 45
SQL> SET FEEDBACK 1
SQL> SET ECHO ON
SQL>
SQL> DROP TABLE employee
2
SQL> CREAT TABLE student
SP2-0734: unknown command beginning "CREAT TABL..." - rest of line ignored.
SQL> CREATE TABLE employee
2 (
3 empno NUMBER(4)CONSTRAINT employee_empno_PK PRIMARY KEY,
4 empname VARCHAR(10),
5 job VARCHAR(10),
6 manager NUMBER(4),
7 hiredate DATE,
8 salary NUMBER(7,2),
9 commission NUMBER(7,2),
10 deptno NUMBER(2)
11 );
Table created.
SQL> INSERT INTO employee
2 VALUES(7839, 'President', NULL, 11/17/1981, 5000, NULL, 10);
INSERT INTO employee
*
ERROR at line 1:
ORA-00947: not enough values
SQL> VALUES(7839, 'President', NULL, '11/17/1978', 5000, NULL, 10);
SP2-0734: unknown command beginning "VALUES(783..." - rest of line ignored.
SQL> INSERT INTO employee
2 VALUES(7839, 'President', NULL, '11/17/1978', 5000, NULL, 10);
INSERT INTO employee
*
ERROR at line 1:
ORA-00947: not enough values
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, 11/17/1981, 5000, NULL, 10);
VALUES(7839, 'King', 'President', NULL, 11/17/1981, 5000, NULL, 10)
*
ERROR at line 2:
ORA-00932: inconsistent datatypes: expected DATE got NUMBER
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, 19811117, 5000, NULL, 10);
VALUES(7839, 'King', 'President', NULL, 19811117, 5000, NULL, 10)
*
ERROR at line 2:
ORA-00932: inconsistent datatypes: expected DATE got NUMBER
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, '11/17/1981', 5000, NULL, 10);
VALUES(7839, 'King', 'President', NULL, '11/17/1981', 5000, NULL, 10)
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, '1978/11/17
3 )
4 ;
ERROR:
ORA-01756: quoted string not properly terminated
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President' NULL, '1978/11/17', 5000, NULL, 10);
VALUES(7839, 'King', 'President' NULL, '1978/11/17', 5000, NULL, 10)
*
ERROR at line 2:
ORA-00917: missing comma
Hello, I am new to MySQL and forgot how to properly INSERT at DATE when using MySQL Plus. I have tried many different variations as you will be able to see and I can't seem to figure it out. I also looked on the internet but always find examples where they make there own formats. What is the correct way to insert a date when the table was created using: hiredate
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, '1981/11/17', 5000, NULL, 10);
VALUES(7839, 'King', 'President', NULL, '1981/11/17', 5000, NULL, 10)
*
ERROR at line 2:
ORA-01861: literal does not match format string
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, '1981/17/11', 5000, NULL, 10);
VALUES(7839, 'King', 'President', NULL, '1981/17/11', 5000, NULL, 10)
*
ERROR at line 2:
ORA-01861: literal does not match format string
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, '17/11/1981', 5000, NULL, 10);
VALUES(7839, 'King', 'President', NULL, '17/11/1981', 5000, NULL, 10)
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, '81/11/17', 5000, NULL, 10);
VALUES(7839, 'King', 'President', NULL, '81/11/17', 5000, NULL, 10)
*
ERROR at line 2:
ORA-01847: day of month must be between 1 and last day of month
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, '17/11/81', 5000, NULL, 100);
VALUES(7839, 'King', 'President', NULL, '17/11/81', 5000, NULL, 100)
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> INSERT INTO employee
2 VALUES(7839, 'King, 'President', NULL, '11/17/1981', 5000, NULL, 10);
ERROR:
ORA-01756: quoted string not properly terminated
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, '11/17/81', 5000, NULL, 10);
VALUES(7839, 'King', 'President', NULL, '11/17/81', 5000, NULL, 10)
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, '17/11/81', 5000, NULL, 10);
VALUES(7839, 'King', 'President', NULL, '17/11/81', 5000, NULL, 10)
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, '81/17/11', 5000, NULL, 10);
VALUES(7839, 'King', 'President', NULL, '81/17/11', 5000, NULL, 10)
*
ERROR at line 2:
ORA-01847: day of month must be between 1 and last day of month
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, '17/81/11', 5000, NULL, 10);
VALUES(7839, 'King', 'President', NULL, '17/81/11', 5000, NULL, 10)
*
ERROR at line 2:
ORA-01843: not a valid month
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, '81/11/17', 5000, NULL, 10);
VALUES(7839, 'King', 'President', NULL, '81/11/17', 5000, NULL, 10)
*
ERROR at line 2:
ORA-01847: day of month must be between 1 and last day of month
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, '1981-11-17', 5000, NULL, 10);
VALUES(7839, 'King', 'President', NULL, '1981-11-17', 5000, NULL, 10)
*
ERROR at line 2:
ORA-01861: literal does not match format string
SQL> INSERT INTO employee
2 VALUES(7839, 'King', 'President', NULL, '17/11/1981', 5000, NULL, 10);
VALUES(7839, 'King', 'President', NULL, '17/11/1981', 5000, NULL, 10)
*
ERROR at line 2:
ORA-01843: not a valid month