SQL statements are not case sensitive. SQL statements can be on one or more lines.

40

description

Writing SQL Statements. SQL statements are not case sensitive. SQL statements can be on one or more lines. Keywords cannot be abbreviated or split across lines. Clauses are usually placed on separate lines. Tabs and indents are used to enhance readability. SQL(Structured Query Language). - PowerPoint PPT Presentation

Transcript of SQL statements are not case sensitive. SQL statements can be on one or more lines.

Page 1: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 2: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 3: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 4: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 5: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 6: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

SQL statements are not case sensitive.

SQL statements can be on one ormore lines.

Keywords cannot be abbreviated or split across lines.

Clauses are usually placed on separate lines.

Tabs and indents are used to enhance readability.

Writing SQL Statements

Page 7: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

SQL(Structured Query Language)

SQL classify the commands in four categories

1- Data Retrival Command.

2- Data Manipulation Language (DML)

3- Data Definition Language (DDL)

4- Data Control Language (DCL)

Page 8: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

Data Retrival Command

This category contains only one command: SELECT. This command is a cornerstone of SQL and allows users to query necessary data from the database. Becouse of its importance and widespread usage, if is often considerd in a separate category of its own.

Page 9: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

Data Manipulation Language (DML)

Commands in this category allow you to manipulate data in existing database objects. The most popular commands in this category are INSERT, UPDATE, and DELETE. Often it is necessary to use the SELECT command to specify the set of data that should be updated or deleted. This is the reson why SELECT sometimes is included in the DML category.

Page 10: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

: البيانات معالجة DMLلغة

القيام بالمهمات التالية: DMLتتيح لك لغة معالجة البيانات - إدراج. 1. UPDATE- تحديث 2. DELETE- حذف 3 البيانات في قاعدة البيانات. SELECT- تحديد 4

العمل مع محتويات قاعدة بياناتك . DMLتتيح لك لغة

Page 11: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

منه SQLأمر الغرض

. الجداول إلى البيانات من صفوف إضافة . الجداول من البيانات من صفوف حذف

. بالجدول الموجودة البيانات تغييرمن البيانات من صفوف استعادة

. عرض/ طريقة جدولالحالية بالعملية الخاصة التغييرات جعل

.) القرص ) على كتابتها دائمةمنذ أجريت التي التغييرات كافة عن التراجع

. إيداع عملية آخر

Insert

Delete

Update

Select

Commit work

Rollback

Page 12: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

Data Definition Language (DDL)

Commands in this category modify the structure of the database by creating, replacing, altering, or droping objects such as tables, indexes, and views.

Page 13: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

: البيانات تعريف DDLلغة

القيام بالمهمات التالية: DDLتتيح لك لغة تعريف البيانات - إنشاء كائن قاعدة البيانات. 1- إسقاط كائن قاعدة البيانات. 2- تغيير كائن قاعدة البيانات. 3- منح امتيازات استخدام كائن قاعدة البيانات. 4- سحب امتيازات استخدام قاعدة البيانات. 5

Page 14: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

Data Control Language (DCL)

This category includes commands that protect the integrity of the database and the consistency of data by controlling and managing the acess to the database structures. These commands are often divided into transaction control commands session control commands, and system control commands.

e.g. create, grand, trancate.

Page 15: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 16: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 17: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 18: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 19: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 20: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 21: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 22: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 23: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 24: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 25: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

SQL and SQL*Plus InteractionSQL and SQL*Plus Interaction

SQL*PlusSQL*Plus

SQL StatementsSQL StatementsBufferBuffer

SQL StatementsSQL Statements

Server

Query ResultsQuery ResultsSQL*PlusSQL*Plus CommandsCommands

Formatted ReportFormatted Report

Page 26: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

SQL and SQL*Plus

SQL is a command language for communication with the Oracle Server from any tool or application. Oracle SQL contains many extensions. When you enter a SQL statement, it is stored in a part of memory called the SQL buffer and remains there until you enter a new statement.

SQL*Plus is an Oracle tool that recognizes and submits SQL statements to the Oracle Server for execution and contains its own command language.

Page 27: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

Features of SQL•Can be used by a range of users, including those with little or no programming experience

•Is a nonprocedural language

•Reduces the amount of time required for creating and maintaining systems

•Is an English-like language

Page 28: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

Features of SQL*Plus•Accepts ad hoc entry of statements

•Accepts SQL input from files

•Provides a line editor for modifying SQL statements

•Controls environmental settings

•Formats query results into a basic report

•Accesses local and remote databases

Page 29: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

SQL Statements Versus SQL*Plus Commands

SQL Statements VersusSQL*Plus Commands

SQLSQLstatementsstatements

SQL SQL

• A languageA language

• ANSI standardANSI standard

• Keyword cannot be Keyword cannot be abbreviatedabbreviated

• Statements manipulate Statements manipulate data and table data and table definitions in the definitions in the databasedatabase

SQL*PlusSQL*Plus

• An environmentAn environment

• Oracle proprietaryOracle proprietary

• Keywords can be Keywords can be abbreviatedabbreviated

• Commands do not Commands do not allow manipulation of allow manipulation of values in the databasevalues in the database

SQLSQLbufferbuffer

SQL*PlusSQL*Pluscommandscommands

SQL*PlusSQL*Plusbufferbuffer

Page 30: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 31: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 32: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 33: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

Capabilities of SQL SELECT Statements

Capabilities of SQL SELECT Statements

SelectionSelection ProjectionProjection

Table 1Table 1 Table 2Table 2

Table 1Table 1 Table 1Table 1JoinJoin

Page 34: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

Basic SELECT StatementBasic SELECT Statement

SELECT [DISTINCT] {*, column [alias],...}FROM table;

SELECT [DISTINCT] {*, column [alias],...}FROM table;

SELECT identifies what columns.FROM identifies which table.

SELECT identifies what columns.FROM identifies which table.

Page 35: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

Selecting All ColumnsSelecting All Columns

DEPTNO DNAME LOC--------- -------------- ------------- 10 ACCOUNTING NEW YORK 20 RESEARCH DALLAS 30 SALES CHICAGO 40 OPERATIONS BOSTON

SQL> SELECT * 2 FROM dept;

Page 36: SQL statements are not case sensitive.  SQL statements can be on one or more lines.

Selecting Specific ColumnsSelecting Specific Columns

DEPTNO LOC--------- ------------- 10 NEW YORK 20 DALLAS 30 CHICAGO 40 BOSTON

SQL> SELECT deptno, loc 2 FROM dept;

Page 37: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 38: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 39: SQL statements are not case sensitive.  SQL statements can be on one or more lines.
Page 40: SQL statements are not case sensitive.  SQL statements can be on one or more lines.