Home > Enterprise >  Creating Table In Oracle PL/SQL
Creating Table In Oracle PL/SQL

Time:08-17

CREATE TABLE my_employee
(
id INT(4) NOT NULL,
last_name VARCHAR2(25),
first_name VARCHAR2(25),
user_id VARCHAR2(8),
salary INT(9, 2)
)

CodePudding user response:

INT datatype can't contain precision nor scale (in Oracle):

SQL> CREATE TABLE my_employee
  2  (
  3     id           INT (4) NOT NULL,
  4     last_name    VARCHAR2 (25),
  5     first_name   VARCHAR2 (25),
  6     user_id      VARCHAR2 (8),
  7     salary       INT (9, 2)
  8  );
   id           INT (4) NOT NULL,
                    *
ERROR at line 3:
ORA-00907: missing right parenthesis

Use NUMBER datatype instead:

SQL> CREATE TABLE my_employee
  2  (
  3     id           NUMBER (4) NOT NULL,
  4     last_name    VARCHAR2 (25),
  5     first_name   VARCHAR2 (25),
  6     user_id      VARCHAR2 (8),
  7     salary       NUMBER (9, 2)
  8  );

Table created.

SQL>
  • Related