Hi friend, once again i am here with new topic "Working with table". Working with table is nothing but in this post we will see, how to create table.
emp12ex correct
123emp incorrect
emp*123 incorrect
emp@123 incorrect
emp_123 correct
emp$123 correct
emp#123 correct
Syntax:
DESC <table_name>
Lets see an example:
DESC emp
We can use both either "DESC" or "DESCRIBE" as we like. For that's all. In next post we will see how to insert data in table. For more keep visiting this blog......
Table:
In oracle database data organized in the form of table which is a combination of rows and column. For creating table there is a syntax that is given bellow:
Syntax:
CREATE TABLE <table_name>
(
column_name1 datatype(size),
column_name2 datatype(size),
column_name3 datatype(size),
column_name4 datatype(size),
column_name5 datatype(size),
----------------
----------------
);
There is some rules that must be follow before creating table:
- Table name should start with alphabets. For example:
emp12ex correct
123emp incorrect
- Table should not contain space and special symbols (except: _,$,#. These special symbols are allowed). For example:
emp*123 incorrect
emp@123 incorrect
emp_123 correct
emp$123 correct
emp#123 correct
- Name of the table can have maximum up-to 30 character.
- A table can have maximum 1000 columns.
Q. Create a table with following structure:
emp
empno
ename
job
sal
hiredate
Ans. ==>
CREATE TABLE emp
(
empno NUMBER(4),
ename VARCHAR2(20),
job VARCHAR2(20),
sal NUMBER(7,2),
hiredate DATE
);
Now lets run this query.
Creating emp table |
Now, here one questing arises that we are created table and forget the structure of table then what to do? For that there is a command that is:
DESCRIBE command
This command is used to see the table data definition or we can say structure. This is also SQLPlus command. Now question is that what is SQLPlus command? what is the different between SQL command and SQLPlus command? Now lets see:
- SQL commands end with semi-clone(;) but in SQLPlus commands there is no need to terminate with semi-clone(;).
- SQL commands can't be abbreviated but SQLPlus commands can be abbreviated. Abbreviation means nothing but sorting the command. For example: We can write "DESCRIBE" command as "DESC".
- SQL command perform operation over database but SQLPlus commands set the environment.
Syntax:
DESC <table_name>
Lets see an example:
DESC emp
See the structure of table |
We can use both either "DESC" or "DESCRIBE" as we like. For that's all. In next post we will see how to insert data in table. For more keep visiting this blog......
No comments:
Post a Comment