How to Create a Table in SQL Plus – Oracle 10G

Today, I would like to share what I have learned while studying oracle.  I’m not going by the books right now as in the books you would learn on how to fetch data from the data base using the select statement but I’m starting of with creating a table.

Before we start, you need to have knowledge about the commonly used data types.  They are char, varchar, number and date. To get more information on data types and their size read Oracle Data Types.

Syntax to Create a Table :

create table tablename (“column1″ “data type” [constraint], “column1″  ‘datatype'[constraint], “column1″ ‘datatype’ [constraint], “column1″  ‘datatype’ [constraint]);

  • “Constraint”  –  we use constraints to limit the type of data that go into a table

Exercise 1

create table team (first_name varchar(20), last_name varchar(20) , sex varchar(10), age varchar(99));

Here team is the tablename , first_name is the column, varchar is the datatype and the values in parenthesis are constraints

oracle 1

That’s how you create a table.  you can create your own table. Check out another example

Example:

create table linkinpark (first_name varchar(20), last_name varchar(20));

 

 

Leave a Reply