DAY 1 - Intro To Oracle and SQL Commands
DAY 1 - Intro To Oracle and SQL Commands
TO
ORACLE AND SQL
COMMANDS
BASIC DEFINITIONS
⮚ Database: A collection of related data.
⮚ Data: Known facts that can be recorded and have an implicit
meaning.
⮚ Database Management System (DBMS): A software
package/ system to facilitate the creation and maintenance of
a computerized database.
⮚ Database System: The DBMS software together with the data
itself. Sometimes, the applications are also included.
ORACLE 11G
https://livesql.oracle.com/apex/f?p=590:1000
INTRODUCTION TO SQL
SQL stands for Structured Query Language.
⮚VARCHAR(size): This data type is used to store variable length alphanumeric data.
It is a flexible form of CHAR data type.
The maximum data this data type can hold is 4000 characters.
⮚NUMBER(P,S): The NUMBER data type is used to store numbers(fixed or floating point).
Numbers of virtually any magnitude maybe stored up to 38 digits of precision.
SQL COMPONENTS
Example:-
Create table STUDENT (Roll_no number(5), Name varchar2(20), Branch
varchar2(10));
Dropping A Column
Alter table <table name> drop column <col name>;
Example:-
Alter table STUDENT add( Telephone number(10));
Alter table STUDENT modify( Telephone number(20));
Alter table STUDENT drop column Telephone;
Example:-
Drop table CSEA_Data101;
INSERT COMMAND
Purpose:- The Insert Into Table command is used to load the created table
with data to be manipulated later.
Example:-
Insert into STUDENT values(101, ‘Aanchal’, ’CSE’);
Insert into STUDENT values(126, ‘Jotnain’, ’CSE’);
Insert into STUDENT values(149, ‘Sapanpreet’, ’ECE’);
Insert into STUDENT values(151, ‘Savita’, ’CSE’);
Example:-
Insert into CSEA_Data101 Select roll_no,name from STUDENT where
roll_no=149;
SELECT COMMAND
Purpose:- This command is used to view all the rows and columns of the
table created in the database.
Example:-
Select * from STUDENT;
SELECT COMMAND
Example:-
Select * from STUDENT where roll_no=151;
ALIAS
Example:-
SELECT CustomerID AS ID, CustomerName AS Customer
FROM Customers;
Example:-
SELECT o.OrderID, o.OrderDate, c.CustomerName
FROM Customers AS c, Orders AS o
WHERE c.CustomerName='Around the
Horn' AND c.CustomerID=o.CustomerID;
DELETE COMMAND
Purpose:- To delete the rows from the table that satisfies the condition
provided by its where clause and returns the number of records deleted.
Example:-
Delete from CSEA_Data101 where rollno=149;
Delete from CSEA_Data101;
DELETE
⮚DELETE is a DML command.
⮚DELETE is executed using a row lock, each row in the table is locked for deletion.
⮚We can use where clause with DELETE to filter & delete specific records.
⮚The DELETE command is used to remove rows from a table based on WHERE
condition.
⮚It maintains the log, so it slower than TRUNCATE.
DROP COMMAND
2. It is used to delete rows or records 2. It is used to delete the entire table 2. It is used to delete the entire
based on conditions specified in the along with its schema and structure records of a table without affecting
WHERE clause. respectively. the schema of the table.
UPDATE COMMAND
Purpose:- The Update statement updates columns in the existing table’s
rows with new values. The Set clause indicates which column data should
be modified and the new valued they should hold.
Syntax:-
Updating Specific Records
Update <table name> set <col name1>=<expression1>, <col
name2>=<expression2> where <condition>;
Updating All The Records
Update <table name> set <col name1>=<expression1>, <col
name2>=<expression2>;
Example:-
Update STUDENT set Branch=’ECE’ where roll_no=101;
Update STUDENT set Branch=’CSE’;
FURTHER READINGS
1. EF Codd’s Rules -- https://www.tutorialcup.com/dbms/codds-rule.htm
2. Introduction to databases.pdf
3. https://nptel.ac.in/courses/106105175/
THANK YOU