1

こんにちは、私は 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
4

2 に答える 2