Friday, December 30, 2016

commands in Oracle dbms

1. show user: show user <user name>;

2. grant resource, connect to <user name>; ----> user get permission to connect with database

3. cl scr; ------> clear screen

4. select * from tab; ----> it will display list of table names, view names & index names from the current schema.

schema: users account is known as schema.
Tab: it is known as table space(storage area)

5. describe table_name(emp_info): it will display the structure of the table, like column names, data types, sizes.

6. Insert Command: this command is used to insert one record into a table at a time.
Syntax:
insert into <table> (col1, col2, col3,......)
values(val1, val2, val3......);

EX: insert into emp_info (eid, ename, sal, desg, jdate)
values(111,'ram', 10000,'developer', '26-may-96');
display: 1 row created:

Note: in the above example, no of values, no of column in the table are equal so it is not necessary to specify column name.

Note: while inserting a record, char & date type value must be written in single course.

EX: insert into emp_table
values('john', 23000, 'programmer');
display: error line 1:
not enough values.

Note: if number of values inserting are less than number of column then:
1. maintain column name
2. maintain null keyword at the place of missed value.

EX: SQL> insert into emp_info(ename, sal, desg)
values('john', 20000, 'programmer');
display: 1 row created.

EX: SQL> insert into emp_info
values(null, 'john', 20000, 'programmer', null);
display: 1 row created.

EX: SQL> insert into emp_info(sal, ename, desg)
values(2000, 'john', 'programmer');
display: 1 row created.
-----------------------------

7. Select Command:
if is a logical command, it is used to fetch data from the tables or views.
Syntax: Select col1, col2... or * or expression or value
from <table name>

EX: get employee name:
select ename from emp_info;

EX:
SQL>select ename, sal, desg from emp_info;
SQL>select * from emp_info;

No comments:

Post a Comment