1 A Guide to SQL Chapter 2. 2 Introduction Mid-1970s: SQL developed under the name SEQUEL at IBM by San Jose research facilities to be the data manipulation.

Slides:



Advertisements
Similar presentations
A Guide to Oracle9i1 Creating and Modifying Database Tables Chapter 2.
Advertisements

Session 2Introduction to Database Technology Data Types and Table Creation.
CC SQL Utilities.
Chapter 8 Embedded SQL.
Let’s try Oracle. Accessing Oracle The Oracle system, like the SQL Server system, is client / server. For SQL Server, –the client is the Query Analyser.
Quick-and-dirty.  Commands end in a semi-colon ◦ If you forget, another prompt line shows up  Either continue the command or…  End it with a semi-colon.
A Guide to SQL, Seventh Edition. Objectives Create a new table from an existing table Change data using the UPDATE command Add new data using the INSERT.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Concepts of Database Management Sixth Edition
5 Chapter 5 Structured Query Language (SQL1) Revision.
Concepts of Database Management, 4th Edition, Pratt & Adamski
30-Jun-15 SQL A Brief Introduction. SQL SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell”
A Guide to SQL, Seventh Edition. Objectives Embed SQL commands in PL/SQL programs Retrieve single rows using embedded SQL Update a table using embedded.
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.
A Guide to SQL, Seventh Edition. Objectives Understand, create, and drop views Recognize the benefits of using views Grant and revoke user’s database.
Structured Query Language. Brief History Developed in early 1970 for relational data model: –Structured English Query Language (SEQUEL) –Implemented with.
Concepts of Database Management Sixth Edition
Chapter 3: SQL – Part I Yong Choi School of Business CSU, Bakersfield.
SQL Query Extras MIS 433. Rerunning the last Query n Type the forward slash “/” to rerun the last query that was entered.
SQL – Part I Yong Choi School of Business CSU, Bakersfield.
MS Access: Database Concepts Instructor: Vicki Weidler.
A Guide to SQL, Eighth Edition Chapter Three Creating Tables.
1 An Introduction to SQL. 2 Objectives  Understand the concepts and terminology associated with relational databases  Create and run SQL commands 
Introduction to SQL Yong Choi School of Business CSU, Bakersfield.
ASP.NET Programming with C# and SQL Server First Edition
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
Concepts of Database Management Seventh Edition
Concepts of Database Management, Fifth Edition Chapter 4: The Relational Model 3: Advanced Topics.
Chapter 4 The Relational Model 3: Advanced Topics Concepts of Database Management Seventh Edition.
Structured Query Language. Brief History Developed in early 1970 for relational data model: –Structured English Query Language (SEQUEL) –Implemented with.
CS 3630 Database Design and Implementation. Your Oracle Account UserName is the same as your UWP username Followed Not case sensitive Initial.
CSC 2720 Building Web Applications Database and SQL.
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Oracle 11g DATABASE DEVELOPMENT LAB1. Introduction  Oracle 11g Database:-  Oracle 11g database is designed for some features, which helps to the organizations.
A Guide to MySQL 3. 2 Introduction  Structured Query Language (SQL): Popular and widely used language for retrieving and manipulating database data Developed.
1 Chapter 6 Database Administration. 2 Introduction Database administration The process of managing a database Database administrator A person or an entire.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
A Guide to SQL, Seventh Edition. Objectives Understand how to use functions in queries Use the UPPER and LOWER functions with character data Use the ROUND.
Features of SQL SQL is an English-like language . It uses words such as select , insert , delete as part of its commend set. SQL is an a non-procedural.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
IS 380 Introduction to SQL This lectures covers material from: database textbook chapter 3 Oracle chapter: 3,14,17.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
A Guide to SQL, Eighth Edition Chapter Eight SQL Functions and Procedures.
Chapter 8 Embedded SQL.
Managing Database With Oracle Replacement for Ch10 COP 4708.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
A Guide to SQL, Eighth Edition Chapter Six Updating Data.
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
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.
A Guide to SQL, Sixth Edition 1 Chapter 5 Updating Data.
1 Chapter 3 Single Table Queries. 2 Simple Queries Query - a question represented in a way that the DBMS can understand Basic format SELECT-FROM Optional.
Chapter 3 Table Creation and Management Oracle 10g: SQL.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
3 A Guide to MySQL.
Fundamentals of DBMS Notes-1.
Retrieving Data Using the SQL SELECT Statement
A Guide to SQL, Seventh Edition
A Guide to SQL, Seventh Edition
SQL and SQL*Plus Interaction
Using SQL*Plus.
ORACLE SQL Developer & SQLPLUS Statements
Chapter 2: Creating And Modifying Database Tables
Using SQL*Plus.
Presentation transcript:

1 A Guide to SQL Chapter 2

2 Introduction Mid-1970s: SQL developed under the name SEQUEL at IBM by San Jose research facilities to be the data manipulation language for IBM’s prototype relational model DBMS, System R 1980: language renamed SQL to avoid confusion with an unrelated hardware product called SEQUEL Currently: SQL used as the data manipulation language for IBM’s current relational DBMS, DB2 Most relational DBMSes use a version of SQL

3 SQL Text Case Sensitivity SQL is not case sensitive Type commands using uppercase or lowercase letters Exception: when inserting character values into a table, use the correct case

4 Qualifying Names To associate the correct table with the column name write both the table name and the column name, separated by a period CUSTOMER.SLSREP_NUMBER SALES_REP.SLSREP_NUMBER This technique of including the table name with the column name is known as qualifying the names

5 Database Creation The SQL command used to describe the layout of a table is CREATE TABLE followed by the name of the table to be created and the names and data types of the columns that comprise the table in parentheses Data type indicates the type of data that the column can contain (for example, characters, numbers, or dates)

6 Typical Column Naming Conventions The name cannot be longer than 18 characters (in Oracle, names can be up to 30 characters in length) The name must start with a letter The name can contain letters, numbers, and underscores ( _ ) The name cannot contain spaces

7 Create Table Command for SALES_REP Table

8 Common Data Types

9 SQL Commands Commands can be entered in a free format no rule says that a particular word must begin in a particular position on a line the manner in which the command is written simply makes the command more readable Press the Enter key at the end of each line and then continue typing the command on the next line Indicate the end of a command line by typing a semicolon

10 Dropping a Table Use the DROP TABLE command to delete a table The command DROP TABLE is followed by the name of the table you want to delete and a semicolon. DROP TABLE SALES_REP; Note when a table is dropped, any data that you entered into the table is dropped

11 Implementation of Nulls CREATE TABLE SALES_REP (SLSREP_NUMBER CHAR(2) NOT NULL, LAST CHAR(10) NOT NULL, FIRST CHAR (5) NOT NULL, STREET CHAR(15), CITY CHAR(15), STATE CHAR(2), ZIP_CODE CHAR(5), TOTAL_COMMISSION DECIMAL(7,2), COMMISSION_RATE DECIMAL(3,2) );

12 Loading a Table with Data Add necessary rows to each table using the INSERT command When adding rows to character (CHAR) columns, make sure to enclose the values in single quotation marks (for example, ‘Jones’)

13 INSERT Command

14 Editing In Oracle, the most recent command entered is stored in the command buffer The easiest way to edit a command is to use the Notepad (type “Edit” at the SQL prompt).

15 Using an Editor to Modify the INSERT Command

16 The INSERT Command with Nulls To enter a null value into a table, use a special format of the INSERT command In this special format, identify the names of the columns that will accept non-null values, and then list only these non-null values after the VALUES command

17 Inserting a Row Containing Null Values

18 Correcting Errors in the Database After reviewing the data in the table changes may have to be made to the value in a column Use the UPDATE command shown in Figure 2.13 to correct errors

19 Modifying the Contents of a Column

20 DELETE Command To delete a record, use the DELETE command The command in Figure 2.14 deletes any row on which the sales rep number is 18

21 Deleting a Row

22 cre_cust.SQL To run the cre_cust.SQL file Save the file Close the editor (and full path if stored in another folder) After creating the table, another file could be created containing all the necessary INSERT commands to add the necessary records to the table Each command must end with a semicolon

23 Describing a Table Use the DESCRIBE command to describe the layout of a table The DESCRIBE command, as shown in Figure 2.23 lists all the columns in the SALES_REP table and their corresponding data types

24 DESCRIBE Command for SALES_REP Table