ch3_SQL_intro

ch3_SQL_intro - Chapter 3 Introduction to SQL Chapter 3...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL ©Silberschatz, Korth and Sudarshan 3.2 Database System Concepts - 6 th Edition Chapter 3: Introduction to SQL Chapter 3: Introduction to SQL ■ Overview of The SQL Query Language ■ Data Definition ■ Basic Query Structure ■ Additional Basic Operations ■ Set Operations ■ Null Values ■ Aggregate Functions ■ Nested Subqueries ■ Modification of the Database ©Silberschatz, Korth and Sudarshan 3.3 Database System Concepts - 6 th Edition History History ■ IBM Sequel language developed as part of System R project at the IBM San Jose Research Laboratory ■ Renamed Structured Query Language (SQL) ■ ANSI and ISO standard SQL: ● SQL-86 ● SQL-89 ● SQL-92 ● SQL:1999 (language name became Y2K compliant!) ● SQL:2003 ■ Commercial systems offer most, if not all, SQL-92 features, plus varying feature sets from later standards and special proprietary features. ● Not all examples here may work on your particular system. ©Silberschatz, Korth and Sudarshan 3.4 Database System Concepts - 6 th Edition Domain Types in SQL Domain Types in SQL ■ char(n). Fixed length character string, with user-specified length n. ■ varchar(n). Variable length character strings, with user-specified maximum length n. ■ int. Integer (a finite subset of the integers that is machine-dependent). ■ smallint. Small integer (a machine-dependent subset of the integer domain type). ■ numeric(p,d). Fixed point number, with user-specified precision of p digits, with n digits to the right of decimal point. ■ real, double precision. Floating point and double-precision floating point numbers, with machine-dependent precision. ■ float(n). Floating point number, with user-specified precision of at least n digits. ■ More are covered in Chapter 4. ©Silberschatz, Korth and Sudarshan 3.5 Database System Concepts - 6 th Edition Create Table Construct Create Table Construct ■ An SQL relation is defined using the create table command: create table r ( A 1 D 1 , A 2 D 2 , ..., A n D n , (integrity-constraint 1 ), ..., (integrity-constraint k )) ● r is the name of the relation ● each A i is an attribute name in the schema of relation r ● D i is the data type of values in the domain of attribute A i ■ Example: create table instructor ( ID char (5), name varchar (20) not null, dept_name varchar (20), salary numeric (8,2)) ■ insert into instructor values (‘10211’, ’Smith’, ’Biology’, 66000); ■ insert into instructor values (‘10211’, null, ’Biology’, 66000); ©Silberschatz, Korth and Sudarshan 3.6 Database System Concepts - 6 th Edition Integrity Constraints in Create Table Integrity Constraints in Create Table ■ not null ■ primary key ( A 1 , ..., A n ) ■ foreign key ( A m , ..., A n ) references r Example: Declare branch_name as the primary key for branch create table instructor ( ID char (5), name varchar (20) not null, dept_name varchar (20), salary numeric (8,2),...
View Full Document

This note was uploaded on 09/10/2011 for the course CS 308 taught by Professor Frankl during the Spring '11 term at NYU Poly.

Page1 / 59

ch3_SQL_intro - Chapter 3 Introduction to SQL Chapter 3...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online