150 likes | 236 Views
Chapter Four. Objectives Introduction to SQL Introduction to iSQL*PLUS Types of SQL statements Concepts of DDL & DML Data Manipulation Language (DML). SQL. Structured Query Language Developed by IBM Used in most Commercial DBMS Statements are not case sensitive.
E N D
Chapter Four Objectives Introduction to SQL Introduction to iSQL*PLUS Types of SQL statements Concepts of DDL & DML Data Manipulation Language (DML)
SQL • Structured Query Language • Developed by IBM • Used in most Commercial DBMS • Statements are not case sensitive. • Statements can be on one or more lines. • Reserved words cannot be abbreviated or split over lines. • Terminated with a semi colon. • Statements are entered at SQL prompt. The subsequent lines are numbered (SQL buffer) • Only one statement can be current at any time in the buffer.
Types of SQL Statements • Data Definition Language (DDL) • Data Manipulation Language (DML)
Data Definition Language Name:User Identifiers: 1-30 characters Start with an alphabet Followed by alphabet, digit, _ Unique Not reserved Not case sensitive
Data Types Oracle Data Types: • CHAR(size) • VARCHAR2(max_size) • NUMBER(n,d) • DATE
Data Types: 1-Character: CHAR(Size) VARCHAR2(MaxSize) ‘4321’ ‘19 Main St. Frostburg’ ‘ * ’ ‘Student’’s ID’
Data Types: 2-Number:NUMBERNUMBER(T,D) 1,234,567.89 NUMBER 1,234,567.89 1,234,567.89 NUMBER(9) 1,234,567 1,234,567.89 NUMBER(9,1) 1,234,567.8 1,234,567.89 NUMBER(7,-2) 1,234,500 1,234,567.89 NUMBER(6) ??
Data Types: • 3-Date:DATE MyBirthdate = ‘11-JAN-37’ • Default time 00:00:00 A.M. • Use TO_DATE()
Display a Structure of a Table: DESCRIBE Student; Name Null? Type ---------------------------------------------------------- NAME VARCHAR2(80) ID NUMBER(9) • GPA NUMBER(3,2) • B_Date DATE • Major CHAR(4)
iSQL*PLUS • iSQL*Plus consists of the following three layers: 1-Client layer (Web browser) 2-Middle layer (Oracle HTTP Server and iSQL*Plus Server) 3-Database layer (Oracle database and Oracle Net)
iSQL*PLUSInterface Configuration • History Size: Set the number of scripts displayed in the script history. • Input Area Size: Set the size of the script input area. -Width -Height
iSQL*PLUSInterface Configuration • Output Location: Set where script output is displayed. -Below Input Area-Save to HTML File • Set whether output is displayed on a single page, or over multiple pages. -Single page -Multiple pages • Number of rows on each page
iSQL*PLUSInterface Configuration • Show Line Numbers -On-Off • Indent Attribute or Column Names -On-Off • Whether commands in scripts are displayed in output as the script is executed. -On-Off
Changing the name of a table: RENAME student TO GradStudent;