In this post you will learn how to create table in Oracle SQL, below syntax will illustrate the basic steps to create table in Oracle SQL
CREATE TABLE schema_name.table_name ( column_1 data_type column_constraint, column_2 data_type column_constraint, ... table_constraint );
Following points you need to remember before creating table into SQL
- First you need to specify the schema and table name
- Within the parentheses you need to specify the columns name with datatype and datasize
- Add table constraints if applicable
Statement To Create Table in Oracle SQL
Below example shows how you can create table under ap schema
CREATE TABLE ap.persons
(
person_id NUMBER GENERATED BY DEFAULT AS IDENTITY,
first_name VARCHAR2(50) NOT NULL,
last_name VARCHAR2(50) NOT NULL,
PRIMARY KEY(person_id)
);