Advertisement
English transcript
What's up internet This is Manish from RebellionRider.com
Today in this oracle database tutorial we will see How to CREATE A TABLE.
I am doing this video on popular demand so sorry for interrupting SQL function series.
We will be continuing with SQL Function series after these SQL CREATE TABLE videos.
Ohk let's start with a brief intro about SQL
table and SQL CREATE TABLE.
if we have to define a table in layman language then we can say that Tables are just a collection
of Rows and Columns but In RDBMS tables are database objects which
help in organizing data into ROWS and COLUMNS. We can also say that
SQL tables are kind of data structure which are used by database for efficient storage
of data.
To create a table in our database we use SQL CREATE TABLE command.
SQL CREATE TABLE is a type of DATA DEFINITION LANGUAGE also known as DDL.
To Create a table in your schema you will require CREATE TABLE system privilege.
In our future videos we will see what are system and object privileges and how to grant
them to a user. Today for this video we will be using Sample
schema HR which already has all the necessary privileges.
Ohk Let's see the syntax. CREATE TABLE table name
( column name1 Data-Type(size),
column name2 Data-Type(size), .....
); CREATE TABLE is an oracle reserved word or
say an Oracle key word whereas table name and column name are user defined
so you can specify whatever name you want to your table and it's columns.
Every column should be separated from each other using commas.
Oracle has a maximum limit of 1000 columns in a table and no limits on rows.
There are 3 different ways of creating a table in Oracle database.
Let's check them out. 1. Creating a table using Command Line Interface
(CLI) in Oracle database For demonstrating how to create table in oracle
database using CLI, I'll be using Command prompt. If you are working on Linux machine
then you can use terminal. Steps are same in both.
Ok Right now I am on my command prompt first of all we have to set the SID of our
database over which we want to work. I have only one database with SID orcl so
set ORACLE_SID = orcl;
Now connect to the schema in which you want to create a table. I'll create a table in
HR sample schema so I am going to connect it with HR
SQLPLUS hr/hr
So now we are in our SQL prompt. let's apply our create table syntax
I am creating a table by the name table 1 This table has 2 columns
t1_id and first_name. You can add as many columns as
you want.
Thats how we create table using command prompt. you can check your table structure by DESCRIBE
command for that just write
DESC and your table name. Like this
Another way of creating a table is by using Graphic user interface (GUI) in Oracle database
To demonstrate how to create table using GUI we will use SQL developer.
Lets open our SQL developer I am connected to HR schema
if you do not know how to create a connection to database using SQL developer please watch
my oracle database tutorial 4 that explains database connectivity using SQL developer
and command prompt. Link for this video is in the description below.
So lets create a table. Creating a table using SQL developer is very
easy we do not have to fire any query here.
Let's start First of all right click on your connection
in which you want to create a table and choose schema browser.
This will open a separate schema browser pane
or you can expend your connection by clicking this + sign and then right click on table
and choose New Table.
However I prefer working with schema browser so let's skip to schema browser pane
here from the first drop-down list you can choose connection name
and in the second drop down list you can choose what database objects you want to work with
we want to create a table thus I'll choose table and then click this arrow here and choose
option for new table Ok we have created a table wizard
first of all give a unique name to your table and add some column as well. For this, click
the green plus button. Now we already have a column so give it some name.
Also choose a datatype from the list and specify any size
you can check this not null column if in case you want to make this a mandatory column
you can also specify default value and constraint If you want to make this column a primary
key you can click here In my future video i'll show you what are
these constraints and different ways of applying them on a column in a table.
for this video we will concentrate on create table only
so when you are done with all your columns click ok Thats your table
You can double click on your table here and can see its structure.
Thats it
In my next video i'll show you a 3rd way of creating table using Enterprise Manager.
Watch out for my soon to be uploaded next video on How to create table using enterprise
manager. Also you can download all the resources used
in this video from my website www.rebellionrider.com/sql-create-table.htm
That's it for today Thanks for watching
This is manish.
Today in this oracle database tutorial we will see How to CREATE A TABLE.
I am doing this video on popular demand so sorry for interrupting SQL function series.
We will be continuing with SQL Function series after these SQL CREATE TABLE videos.
Ohk let's start with a brief intro about SQL
table and SQL CREATE TABLE.
if we have to define a table in layman language then we can say that Tables are just a collection
of Rows and Columns but In RDBMS tables are database objects which
help in organizing data into ROWS and COLUMNS. We can also say that
SQL tables are kind of data structure which are used by database for efficient storage
of data.
To create a table in our database we use SQL CREATE TABLE command.
SQL CREATE TABLE is a type of DATA DEFINITION LANGUAGE also known as DDL.
To Create a table in your schema you will require CREATE TABLE system privilege.
In our future videos we will see what are system and object privileges and how to grant
them to a user. Today for this video we will be using Sample
schema HR which already has all the necessary privileges.
Ohk Let's see the syntax. CREATE TABLE table name
( column name1 Data-Type(size),
column name2 Data-Type(size), .....
); CREATE TABLE is an oracle reserved word or
say an Oracle key word whereas table name and column name are user defined
so you can specify whatever name you want to your table and it's columns.
Every column should be separated from each other using commas.
Oracle has a maximum limit of 1000 columns in a table and no limits on rows.
There are 3 different ways of creating a table in Oracle database.
Let's check them out. 1. Creating a table using Command Line Interface
(CLI) in Oracle database For demonstrating how to create table in oracle
database using CLI, I'll be using Command prompt. If you are working on Linux machine
then you can use terminal. Steps are same in both.
Ok Right now I am on my command prompt first of all we have to set the SID of our
database over which we want to work. I have only one database with SID orcl so
set ORACLE_SID = orcl;
Now connect to the schema in which you want to create a table. I'll create a table in
HR sample schema so I am going to connect it with HR
SQLPLUS hr/hr
So now we are in our SQL prompt. let's apply our create table syntax
I am creating a table by the name table 1 This table has 2 columns
t1_id and first_name. You can add as many columns as
you want.
Thats how we create table using command prompt. you can check your table structure by DESCRIBE
command for that just write
DESC and your table name. Like this
Another way of creating a table is by using Graphic user interface (GUI) in Oracle database
To demonstrate how to create table using GUI we will use SQL developer.
Lets open our SQL developer I am connected to HR schema
if you do not know how to create a connection to database using SQL developer please watch
my oracle database tutorial 4 that explains database connectivity using SQL developer
and command prompt. Link for this video is in the description below.
So lets create a table. Creating a table using SQL developer is very
easy we do not have to fire any query here.
Let's start First of all right click on your connection
in which you want to create a table and choose schema browser.
This will open a separate schema browser pane
or you can expend your connection by clicking this + sign and then right click on table
and choose New Table.
However I prefer working with schema browser so let's skip to schema browser pane
here from the first drop-down list you can choose connection name
and in the second drop down list you can choose what database objects you want to work with
we want to create a table thus I'll choose table and then click this arrow here and choose
option for new table Ok we have created a table wizard
first of all give a unique name to your table and add some column as well. For this, click
the green plus button. Now we already have a column so give it some name.
Also choose a datatype from the list and specify any size
you can check this not null column if in case you want to make this a mandatory column
you can also specify default value and constraint If you want to make this column a primary
key you can click here In my future video i'll show you what are
these constraints and different ways of applying them on a column in a table.
for this video we will concentrate on create table only
so when you are done with all your columns click ok Thats your table
You can double click on your table here and can see its structure.
Thats it
In my next video i'll show you a 3rd way of creating table using Enterprise Manager.
Watch out for my soon to be uploaded next video on How to create table using enterprise
manager. Also you can download all the resources used
in this video from my website www.rebellionrider.com/sql-create-table.htm
That's it for today Thanks for watching
This is manish.