How to create a new table in Oracle?
To create a new table, we can choose to compose a hand-writing PL/SQL statement which may be lengthy, complex, and error-prone. Or, we can also use handy GUI tools like PL/SQL developer to reach the goal.
PL/SQL developer is a GUI tool for connecting Oracle, which is mainly used by developers who want to create some schema objects and program stored procedures in an easier and visualized way.
In this post, I'd like to illustrate how to create a table in PL/SQL Developer step by step. For creating tables in SQL developer, there's also a tutorial for you.
Let's see the procedure.
New a Table
We click on the icon of blank document and click "Table" to initiate the table creation.
We enter table name, comment etc in the first tab.
We can add some more columns for the table in "Columns" tab.
Please note that, not null columns should uncheck "Nullable".
To add primary key, unique key or foreign key, we can go for "Keys" tab. Here we add a primary key for the table.
Please note that, the tool uses out_of_line_constraint to create primary key, unique key or foreign key. To create nonunique (normal) indexes, you should go for "Indexes".
To add more constraints, we can go for "Constraints" tab. Here we add a check constraint for a column.
To add more indexes, we can go for "Indexes" tab. Here we create a nonunique (normal) index for a column.
We click "View SQL" to preview DDL of the table.
We preview the final result by viewing the DDL before actually creating it.
We click "Apply" to confirm the table creation.
We click "Close" to close the window.
In the table list, we can see its definition.
We have created a new table in PL/SQL developer.