ACTION QUERIES (SQL COMMANDS ) STRUCTURED QUERY LANGUAGE.

Slides:



Advertisements
Similar presentations
SQL Rohit Khokher.
Advertisements

BACS 485—Database Management Advanced SQL Overview Advanced DDL, DML, and DCL Commands.
Basic SQL Introduction Presented by: Madhuri Bhogadi.
Virtual training week 4 structured query language (SQL)
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
9-1 Copyright  Oracle Corporation, All rights reserved. Data Manipulation Language A DML statement is executed when you: – Add new rows to a table.
Introduction To SQL Lynnwood Brown President System Managers LLC Copyright System Managers LLC 2003 all rights reserved.
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
SQL Components DML DDL DAL. Overview u Getting the records onto the disk - mapping u Managing disk space u SQL Modes u Ceating database.
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
Structured Query Language S Q L. What is SQL It is a database programming language developed by IBM in the early 1970’s. It is used for managing and retrieving.
Introduction to DBMS and SQL Introduction to DBMS and SQL GUIDED BY : MR. YOGESH SAROJ (PGT-CS) MR. YOGESH SAROJ (PGT-CS) Presented By : JAYA XII –COM.
ORACLE SQL. Overview Personal DBMS Vs Client/Server DBMS Oracle 8 Environment SQL – syntax and examples PL/SQL-introduction.
o At the end of this lesson, you will be able to:  Describe the life-cycle development phases  Discuss the theoretical and physical aspects of a relational.
Creating a Table Create a table, “emp”, containing: –empno – a 4 digit employee number –ename – up to 10 character string –job – up to 9 character string.
SQL (DDL & DML Commands)
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
1 Information Retrieval and Use (IRU) CE An Introduction To SQL Part 1.
SQL FUNDAMENTALS SQL ( Structured Query Language )
DATA MANIPULATION andCONTROL
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
10 Creating and Managing Tables Objectives At the end of this lesson, you will be able to: Describe the main database objects Create tables Describe.
Quick review of SQL And conversion to Oracle SQL.
10-1 Copyright  Oracle Corporation, All rights reserved. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns.
Nitin Singh/AAO RTI ALLAHABAD 1 SQL Nitin Singh/AAO RTI ALLAHABAD 2 OBJECTIVES §What is SQL? §Types of SQL commands and their function §Query §Index.
SQL. Relating Multiple Tables Relational Database Terminology Row PK Column FK Field NULL.
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
Session 2: SQL (A): Parts 1 and 2 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
SQL Structured Query Language 1. Data Definition Language (DDL) is used to manage table and define data structure i.e. CREATE, ALTER, DROP Data Control.
SQL SeQueL -Structured Query Language SQL SQL better support for Algebraic operations SQL Post-Relational row and column types,
Tables and Constraints Oracle PL/SQL. Datatypes The SQL Data Definition Language Commands (or DDL) enable us to create, modify and remove database data.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Copyright  Oracle Corporation, All rights reserved. Introduction.
Copyright  Oracle Corporation, All rights reserved. 4 Introduction.
SQL: Part 1 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram. Not for commercial.
DBSQL 5-1 Copyright © Genetic Computer School 2009 Chapter 5 Structured Query Language.
Database Programming Sections 14– database transactions and controlling User Access.
Enhanced Guide to Oracle 10g Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data.
DATA, INFORMATION AND KNOWLEDGE Data: Data can be anything such as a number, a person’s name, images, crops name, sounds and so on. It can be defined as.
An Introduction To SQL Part 2 (Special thanks to Geoff Leese)
1 Information Retrieval and Use (IRU) An Introduction To SQL Part 2.
Altering Tables and Constraints Database Systems Objectives Add and modify columns. Add, enable, disable, or remove constraints. Drop a table. Remove.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Agenda for Class - 03/04/2014 Answer questions about HW#5 and HW#6 Review query syntax. Discuss group functions and summary output with the GROUP BY statement.
Database Management 4. course. Reminder Relational algebra – Operators – Join Relational calculus – Formulas SQL – DDL.
CSCI N311: Oracle Database Programming 5-1 Chapter 15: Changing Data: insert, update, delete Insert Rollback Commit Update Delete Insert Statement –Allows.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
SQL: Structured Query Language It enables to create and operate on relational databases, which are sets of related information stored in tables. It is.
LECTURE FOUR Introduction to SQL DDL with tables DML with tables.
SQL Statements SELECT INSERTUPDATEDELETECREATEALTERDROPRENAMETRUNCATECOMMITROLLBACKSAVEPOINTGRANTREVOKE Data Retrieval Language (DRL) Data Retrieval Language.
Advanced SQL. SQL - Nulls Nulls are not equal to anything - Null is not even equal to Null where columna != ‘ABC’ --this will not return records where.
SQL Query Getting to the data ……..
The Basics of Data Manipulation
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
Manipulating Data Schedule: Timing Topic 40 minutes Lecture
Interacting with the Oracle Server
DATABASE MANAGEMENT SYSTEM
جملة الاستعلام الأساسية
The Basics of Data Manipulation
SQL data definition using Oracle
Data Control Language Grant, Revoke.
مقدمة في قواعد البيانات
SQL Statements SELECT INSERT UPDATE DELETE CREATE ALTER DROP RENAME
ORACLE SQL.
SQL Fundamentals in Three Hours
Database Programming Using Oracle 11g
SQL (Structured Query Language)
Presentation transcript:

ACTION QUERIES (SQL COMMANDS ) STRUCTURED QUERY LANGUAGE

ACTION QUERIES (SQL COMMANDS) DATA DEFINITION LANGUAGE DATA MANIPULATION LANGUAGE TRANSACTION CONTROL LANGUAGE DATA CONTROL LANGUAGE

DATA DEFINITION LANGUAGE (DDL ) CREATE ALTER DROP TRUNCATE

DATA MANIPULATION LANGUAGE (DML ) INSERT UPDATE DELETE

TRANSACTION CONTROL LANGUAGE (TCL) COMMIT ROLLBACK SAVEPOINT

DATA CONTROL LANGUAGE (DCL) GRANT REVOKE

DATA TYPES NUMBER (FLOAT) VARCHAR2 DATE 40 DIGITS +SPACE FOR A DECIMAL AND A SIGN UPTO 4000 BYTES 7 DIGITS

TO CREATE A TABLE CREATE TABLE TABLENAME (ATTRIBUTE1 DATATYPE, ATTRIBUTE2 DATATYPE,....);

TO ALTER A TABLE & ADD A COLUMN ALTER TABLE TABLENAME ADD ATTRIBUTE DATATYPE;

TO VIEW THE TABLE SELECT * FROM TABLENAME ;

TO ALTER A TABLE AND MODIFY DATATYPE Alter table tablename modify attribute datatype; (PROVIDED THERE IS NO VALUE IN THE COLUMN)

TO RENAME A TABLE Rename oldtablename to newtablename;

TO DROP A TABLE Drop table tablename;

TO TRUNCATE A TABLE TRUNCATE TABLE TABLENAME;

To insert values into a table INSERT INTO TABLENAME VALUES(VALUE1,VALUE2, VALUE3....);

TO UPDATE VALUES Update tablename set column1=value1, column2=value2 where columnname=value ;

To delete values from a table Delete from tablename where columnname=value;

TO SAVE CHANGES PERMANENT/ TEMPORARY COMMIT; ROLLBACK; SAVEPOINT;

EXAMPLES FOR COMMIT AND ROLLBACK SELECT * FROM EMP; DELETE FROM EMP; Insert into emp(empno) values(1000);

COMMIT; (CHANGES ARE PERMANENT) Insert into emp(empno) values(4000); DELETE FROM EMP;

ROLLBACK; (CHANGES MADE AFTER THE COMMIT OR DDL WILL GET ERASED )

EXAMPLES OF COMMIT, ROLLBACK AND SAVEPOINT UPDATE EMP SET EMPNO=4000 WHERE EMPNO=5000; SAVEPOINT A; INSERT INTO EMP(EMPNO) VALUES(1000); SAVEPOINT B;

INSERT INTO EMP(ENAME) VALUES(‘JAGAN’); ROLLBACK TO B; (CHANGES MADE AFTER THE ROLLBACK B WILL GET ERASED) ROLLBACK TO A; (CHANGES MADE AFTER THE ROLLBACK A WILL GET ERASED)

TO VIEW ROWS WITH SALARY BETWEEN 2000 & 4000 Select ename, sal from ex16 where sal between 2000 and 4000;

TO VIEW PERSONS WHOSE NAME HAS LETTER “A” Select ename from ex16 where ename like ‘%a%’;

TO VIEW PERSONS WHOSE NAME STARTS WITH LETTER “A” Select ename from ex16 where ename like ‘a%’;

FUNCTIONS AGGREGATE FUNCTIONS

MAX (TO FIND THE MAXIMUM VALUE ON THE SET OF VALUES) Select max(salary) from emp;

MIN (TO FIND THE MINIMUM VALUE ON THE SET OF VALUES) SELECT MIN(SALARY) FROM EMP;

MORE EXAMPLES SELECT ENAME, HIREDATE FROM EMP WHERE ENAME<>’RAMAN’ AND DEPTNO=(SELECT DEPTNO FROM EMP WHERE ENAME=‘ASHOK’;

MORE EXAMPLES SELECT EMPNO, ENAME, SAL FROM EMP WHERE SAL>(SELECT AVG(SAL) FROM EMP) ORDER BY SAL DESC;

MORE EXAMPLES SELECT EMPNO, ENAME FROM EMP WHERE DEPTNO IN (SELECT DEPTNO FROM EMP WHERE ENAME LIKE ‘%T%’);

MORE EXAMPLES SELECT ENAME, DEPTNO, JOB WHERE DEPTNO=(SELECT DEPTNO FROM DEPT WHERE LOC=‘DALLAS’);

MORE EXAMPLES SELECT ENAME, SAL FROM EMP WHERE MGR=(SELECT EMPNO FROM EMP WHERE ENAME=‘KING’);

MORE EXAMPLES SELECT DEPTNO, ENAME, JOB FROM EMP WHERE DEPTNO=(SELECT DEPTNO FROM DEPT WHERE DNAME=‘SALES’);

MORE EXAMPLES SELECT ENAME, HIREDATE FROM EMP WHERE HIREDATE=(SELECT MAX(HIREDATE) FROM EMP;

MORE EXAMPLES SELECT EMPNO, ENAME FROM EMP WHERE DEPTNO IN (SELECT DEPTNO FROM EMP WHERE ENAME LIKE ‘%T%’ AND SAL>(SELECT AVG(SAL) FROM EMP));

MORE EXAMPLES SELECT ENAME, DEPTNO, SAL FROM EMP WHERE (DEPTNO, SAL) IN (SELECT DEPTNO, SAL FROM EMP WHERE COMM IS NOT NULL);

MORE EXAMPLES SELECT ENAME, JOB, SAL FROM EMP WHERE SAL>ANY(SELECT SAL FROM EMP WHERE JOB=‘CLERK’) ORDER BY SAL DESC;