Introduction to SQL in Oracle.

Introduction to SQL in Oracle.

 

SQL was invented and developed by IBM in the early 1970’s. SQL stands for Structured Query Language. IBM was able to demonstrate how to control relational databases using SQL.. The SQL implemented by ORACLE CORPORATION is 100% compliant with the ANSI/ ISO standard SQL data language. Oracle’s database language is SQL, which is used for storing and retrieving information in Oracle. A table is a primary database object of SQL that is used to store data. A table holds data in the form of rows and columns.

 

In order to communicate with the database, SQL supports the following categories of commands:-

Data Definition Language – create, alter, drop commands.

Data Manipulation Language – insert, select, delete and update commands.

Transaction Control Language – commit, savepoint and rollback commands.

Data Control Language – grant and revoke commands

 

The following are the benefits of SQL:

Non-procedural language, because more than one record can be accessed rather than one record at a time.

It is the common language for all relational databases. In other words it is portable and it requires very few modifications so that it can work on other databases.

♦ Very simple commands for querying, inserting, deleting and modifying data and

objects.

Data Definition Language:

DDL consists of these commands,

  1. Create
  2. Alter
  3. Truncate
  4. Drop

 

1. Create command:

SQL> create table names(first_name varchar2(20), last_name varchar2(20));

Table created.

 

2. Alter Command:

SQL> alter table names modify (ename varchar2(50));

Table altered.

 

3. Truncate Command:

SQL> truncate table names;

Table truncated.

 

4. Drop Command:

SQL> drop table names;

Table dropped.

 

 

Data Manipulation Language:

DML consists of these commands,

  1. Insert
  2. Delete
  3. Update
  4. Merge

 

1. Insert Command:

SQL> insert into names values (‘virat’,’kohli’);

1 row created.

 

2. Delete Command:

SQL> delete from names;

1 row deleted.

 

3. Update Command:

SQL> update names set DOB=’01-dec-2000′ where First_name=’virat’;

1 row updated.

 

 

Transaction Control Language:

TCL consists of these command,

  1. Commit
  2. Rollback

 

1. Commit Command:

SQL> commit;

Commit complete.

 

2. Roll back Command:

SQL> roll back
Rollback complete.

 

 

Data Control Language:

DCL consists of these commands,

  1. Grant
  2. Revoke

 

1. Grant Command:

SQL> grant select on names to thomas;

Grant succeeded.

 

2. Revoke Command:

SQL> revoke select on names from thomas;

Revoke succeeded.

 

 

See Also: