This post will guide you to create your first database table using pl/sql developer.
Please follow this step by step guide to create your first database table.
Step 1: Open PL/SQL developer. Go to Tools –> Browser (Check this option) . A Browser window appears.
Step 2: Now in Browser window go to table folder and right click in table –> Click New.
Step 3: A new Create table window appears. Enter the table name and comments all other fields are optional . You can fill other fields as per your requirement. like if you want to create a global temporary table just check temporary option under Duration.
Step 4: Enter the columns you need in new table. like i added two columns 1. id_test and it is not null and primary column. and second is name type of varchar 2 and size is 100 characters.
Step 5: Add a primary key in keys tab. i added pk_id for column id_test.
Step 6: System already added a index on primary key. you can check in indexes column. You can create more indexed on any column.
Step 7: Click on View SQL bottom on bottom right corner and you can check the sql query of all the setting we done for table creation. You can copy this query and save it and you can directly run it from SQL command prompt to create a table.
Here is text for of the SQL query. You can use this query to create a simple table just remove the SYS. from this query and run on SQL command prompt.
-- Create table
create table SYS.TB_Test
(
id_test number not null,
Name varchar2(100)
)
;
-- Add comments to the table
comment on table SYS.TB_Test
is 'A Test Table';
-- Add comments to the columns
comment on column SYS.TB_Test.id_test
is 'primary key';
-- Create/Recreate primary, unique and foreign key constraints
alter table SYS.TB_Test
add constraint pk_id primary key (ID_TEST);
The new table is create “TB_TEST” at browser window. Just Refresh the browser and you will able to see this table at list.
0 comments:
Post a Comment