Date post: | 03-Jan-2016 |
Category: |
Documents |
Upload: | lani-lawson |
View: | 16 times |
Download: | 0 times |
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
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)
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.
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.
: البيانات معالجة DMLلغة
القيام بالمهمات التالية: DMLتتيح لك لغة معالجة البيانات - إدراج. 1. UPDATE- تحديث 2. DELETE- حذف 3 البيانات في قاعدة البيانات. SELECT- تحديد 4
العمل مع محتويات قاعدة بياناتك . DMLتتيح لك لغة
منه SQLأمر الغرض
. الجداول إلى البيانات من صفوف إضافة . الجداول من البيانات من صفوف حذف
. بالجدول الموجودة البيانات تغييرمن البيانات من صفوف استعادة
. عرض/ طريقة جدولالحالية بالعملية الخاصة التغييرات جعل
.) القرص ) على كتابتها دائمةمنذ أجريت التي التغييرات كافة عن التراجع
. إيداع عملية آخر
Insert
Delete
Update
Select
Commit work
Rollback
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.
: البيانات تعريف DDLلغة
القيام بالمهمات التالية: DDLتتيح لك لغة تعريف البيانات - إنشاء كائن قاعدة البيانات. 1- إسقاط كائن قاعدة البيانات. 2- تغيير كائن قاعدة البيانات. 3- منح امتيازات استخدام كائن قاعدة البيانات. 4- سحب امتيازات استخدام قاعدة البيانات. 5
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.
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
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.
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
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
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
Capabilities of SQL SELECT Statements
Capabilities of SQL SELECT Statements
SelectionSelection ProjectionProjection
Table 1Table 1 Table 2Table 2
Table 1Table 1 Table 1Table 1JoinJoin
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.
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;
Selecting Specific ColumnsSelecting Specific Columns
DEPTNO LOC--------- ------------- 10 NEW YORK 20 DALLAS 30 CHICAGO 40 BOSTON
SQL> SELECT deptno, loc 2 FROM dept;