1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.

Slides:



Advertisements
Similar presentations
CIT 613: Relational Database Development using SQL Revision of Tables and Data Types.
Advertisements

9 Creating and Managing Tables. Objectives After completing this lesson, you should be able to do the following: Describe the main database objects Create.
Data Definition Language (DDL)
Copyright  Oracle Corporation, All rights reserved. 10 Creating and Managing Tables.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
Structured Query Language - SQL Carol Wolf Computer Science.
Introduction to Structured Query Language (SQL)
SQL components In Oracle. SQL in Oracle SQL is made up of 4 components: –DDL Data Definition Language CREATE, ALTER, DROP, TRUNCATE. Creates / Alters.
Database Modifications A modification command does not return a result as a query does, but it changes the database in some way. There are three kinds.
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.
Introduction to Structured Query Language (SQL)
A Guide to MySQL 3. 2 Objectives Start MySQL and learn how to use the MySQL Reference Manual Create a database Change (activate) a database Create tables.
Database Management System LICT 3011 Eyad H. Elshami.
DATABASES AND SQL. Introduction Relation: Relation means table(data is arranged in rows and columns) Domain : A domain is a pool of values appearing in.
Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial Password: UWPstudent Password is case sensitive.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
Database Design lecture 3_1 1 Database Design Lecture 3_1 Data definition in SQL.
SQL data definition using Oracle1 SQL Data Definition using Oracle.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
CHAPTER:14 Simple Queries in SQL Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
SQL data definition using Oracle1 SQL Data Definition using Oracle.
CSC 2720 Building Web Applications Database and SQL.
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
Chapter 5: Part 1: DDL STRUCTURED QUERY LANGUAGE (SQL)
SQL FUNDAMENTALS SQL ( Structured Query Language )
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.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
10-1 Copyright  Oracle Corporation, All rights reserved. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
CS146 References: ORACLE 9i PROGRAMMING A Primer Rajshekhar Sunderraman
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
Chapter 8: SQL. Data Definition Modification of the Database Basic Query Structure Aggregate Functions.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
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.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
9 Copyright © Oracle Corporation, All rights reserved. Creating and Managing Tables.
SQL CREATING AND MANAGING TABLES lecture4 1. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns ViewLogically.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
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)
Basic SQL*Plus edit and execute commands SQL*Plus buffer and built-in editor holds the last SQL statement Statements are created in free-flow style and.
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.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
 CONACT UC:  Magnific training   
8 Copyright © 2005, Oracle. All rights reserved. Managing Schema Objects.
Physical Model Lecture 11. Physical Data Model The last step is the physical design phase, In this phase data is – Store – Organized and – Access.
Creating and Managing Tables. Database Objects ObjectDescription TableBasic unit of storage; composed of rows and columns ViewLogically represents subsets.
Relational Databases and SQL The relational model and the most common SQL commands.
3 A Guide to MySQL.
Fundamentals of DBMS Notes-1.
CS 3630 Database Design and Implementation
Chapter 5 Introduction to SQL.
SQL Creating and Managing Tables
ORACLE SQL Developer & SQLPLUS Statements
DATABASE MANAGEMENT SYSTEM
SQL Creating and Managing Tables
STRUCTURED QUERY LANGUAGE
SQL Creating and Managing Tables
SQL data definition using Oracle
SQL.
Database Management System
Introduction to Oracle
SQL (Structured Query Language)
Presentation transcript:

1 Structured Query Language (SQL)

2 Contents SQL – I SQL – II SQL – III SQL – IV

3 SQL- I Table Fundamentals –Oracle Data Types Basic Data Types –The CREATE TABLE Command Rules for Creating Tables A brief checklist when creating tables –Inserting data into tables Viewing data in the tables –All rows and all columns –Filtering table data Selected columns and all rows Selected rows and all columns Selected columns and selected rows Eliminating duplicate rows when using SELECT statement Sorting data in a table Creating a table from a table Inserting data into a table from another table –Insertion of a data set into a table from another table

4 Delete Operations –Removal all rows –Removal of specific row (s) –Removal of specific row (s) based on the data held by the other table Updating the contents of a table –Updating all rows –Updating records conditionally Modifying the structure of tables –Adding new columns –Dropping a column from a table –Modifying existing columns –Restrictions on the ALTER TABLE Renaming tables Truncating tables Destroying tables Examining objects created by a user

5 Table Fundamentals: A table is database object that holds user data –Oracle Data Types Basic Data Types char (size) – fixed length string. varchar (size)/varchar2 (size) – variable length string date - number (p, s) – precision, scale, eg. number (7, 2) 5 digit before decimal and 2 after. long – variable length string raw/ long raw – variable length binary string –The CREATE TABLE Command Rules for Creating Tables a name can have maximum up to 30 characters. alphabets from A-Z, a-Z and numbers from 0-9 are allowed. a name should begin with an alphabets. the use of special character like _ is allowed SQL reserved words not allowed A brief checklist when creating tables attributes, data types, primary key, default values CREATE TABLE ( ( ), ( ));

6 –Inserting data into tables Viewing data in the tables SELECT –All rows and all columns SELECT * FROM ; –Filtering table data Selected columns and all rows SELECT, FROM ; Selected rows and all columns SELECT * FROM WHERE ; Selected columns and selected rows SELECT, FROM WHERE ; INSERT INTO (, ) VALUES (, );

7 Eliminating duplicate rows when using SELECT statement DISTINCT SELECT DISTINCT * FROM ; Sorting data in a table SELECT * FROM ORDER BY, ; Sort Order: DESC Creating a table from a table CREATE TABLE (, ) AS SELECT, FROM ; eg. Create table to retrieve the table structure. WHERE Inserting data into a table from another table INSERT INTO SELECT, FROM ; –Insertion of a data set into a table from another table INSERT INTO SELECT, FROM WHERE ;

8 Delete Operations DELETE –Removal all rows DELETE FROM ; –Removal of specific row (s) DELETE FROM WHERE ; –Removal of specific row (s) based on the data held by the other table EXISTS DELETE FROM table1 WHERE Exists (SELECT fname FROM tabel2 WHERE table2.cust_no = table1. code_no AND table2.fname = “abc”); Updating the contents of a table UPDATE –Updating all rows UPDATE SET =, = ; –Updating records conditionally UPDATE SET =, = WHERE ;

9 Modifying the structure of tables ALTER TABLE –Adding new columns ALTER TABLE ADD ( ( ), ( ),..); –Dropping a column from a table ALTER TABLE DROP COLUMN ; –Modifying existing columns ALTER TABLE MODIFY ( ( )); –Restrictions on the ALTER TABLE Change the name of the table Change the name of the column Decrease the size of a column if table data exists9 Renaming tables RENAME TO ; Truncating tables: empties a table completely. TRUNCATE TABLE ; Destroying tables DROP TABLE ;

10 Examining objects created by a user – SELECT * FROM TAB; – DESCRIBE ;