SQL Queries_05
SQL Queries_05
DDL (Data Definition Language) statements are used to define the database ROLLBACK - restore database to original since the last COMMIT JOIN & IT’S TYPE
structure or schema. Some examples QUERIES
CREATE - to create objects in the database A JOIN clause is used to combine rows from two or more tables, based on
ALTER - alters the structure of the database 1) CREATE:
a related column between them.
DROP - delete objects from the database Create table client_master (c_no varchar2(5), name varchar2(10), address
1. INNER JOIN:
TRUNCATE - remove all records from a table, including all spaces varchar2(20), pincode number(6), bal_due number(10,2));
Syntax : SELECT column_name(s)
allocated for the records are removed 2) ALTER:
FROM table1
COMMENT - add comments to the data dictionary ALTER TABLE BRANCH_MSTR ADD(CITY VARCHAR2(25));
INNER JOIN table2
RENAME - rename an object ALTER TABLE BRANCH_MSTR DROP COLUMN CITY;
ON table1.column_name = table2.column_name;
3) DROP:
DROP TABLE BRANCH_MSTR; 2. LEFT JOIN:
DML
4) RENAME: Syntax : SELECT column_name(s)
DML (Data Manipulation Language) statements are used for managing data RENAME BRANCH_MSTR TO BRANCH; FROM table1
within schema objects. Some examples: 5) TRUNCATE: LEFT JOIN table2
SELECT -retrieve data from the a database TRUNCATE TABLE BRANCH_MSTR; ON table1.column_name = table2.column_name;
INSERT - insert data into a table 6) SELECT:
SELECT * FROM client_master; 3. RIGHT JOIN:
UPDATE - updates existing data within a table
SELECT c_no, name FROM client_master; Syntax : RIGHT JOIN Syntax
DELETE - deletes all records from a table, the space for the records
7) INSERT: SELECT column_name(s)
remain
INSERT INTO client_master (c_no, name, address, pincode, FROM table1
MERGE - UPSERT operation (insert or update)
bal_due) VALUES (‘C001’, ‘Ajay’, ‘Ahmedabad’, 380063, 500 ); RIGHT JOIN table2
CALL - call a PL/SQL or Java subprogram
8) UPDATE: ON table1.column_name = table2.column_name;
EXPLAIN PLAN - explain access path to data
LOCK TABLE - control concurrency UPDATE ADDR_DTLS SET City = ‘Ahmedabad’;
9) DELETE: 4. FULL OUTER JOIN:
DELETE FROM ACCT_DTLS WHERE ACCT_NO LIKE ‘SB%’; Syntax : FULL OUTER JOIN Syntax
DCL
10) GRANT: SELECT column_name(s)
GRANT SELECT ON Ankit.TRANS_MSTR TO Jashvant; FROM table1
DCL is data control language statements.
11) REVOKE: FULL OUTER JOIN table2
GRANT: gives user’s access privileges to database
REVOKE DELETE ON NOMIEE_MSTR FROM Rahul; REVOKE ON table1.column_name = table2.column_name
REVOKE: withdraw access privileges given with the GRANT command
ALL ON NOMIEE_MSTR FROM Anil; WHERE condition;
Course Name :DBMS Prepared by :- Mr.Ved Panchal ,Mr.Saurabh Prajapati ,Mr.Bhautik Prajapati ,Mr.Rohan Patil