You can create a table in ORACLE database using the CREATE TABLE statement.
The basic syntax is described as follows:
CREATE TABLE schema_name.table_name (column1 data_type column_constraint,column2 data_type column_constraint,...column_n data_type column_constraint,table_constraints);
NUMBER, FLOAT, or VARCHAR2.NULL or NOT NULL. Default is NULL incase left blank.PRIMARY KEY, FOREIGN KEY, and CHECK can be applied to the table if applicable.Below is an example of how to create a simple table in the current schema in ORACLE database:
CREATE TABLE students (student_id number(10) NOT NULL,student_name varchar2(50) NOT NULL);
Below is an example of how to create a table with constraints in the current schema:
CREATE TABLE students (student_id number(10) NOT NULL,student_name varchar2(50) NOT NULL,CONSTRAINT student_key PRIMARY KEY (student_id));
Below is an example of how to create a table with constraints in a different schema:
CREATE TABLE studentsDB.students (student_id number(10) NOT NULL,student_name varchar2(50) NOT NULL,CONSTRAINT student_key PRIMARY KEY (student_id));
Names can also be written within inverted commas, like “students”.