Upload
preston-hodge
View
214
Download
0
Embed Size (px)
Citation preview
Features of SQLSQL 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 language :
SQL processes sets of records rather than a single record at a time . The most common form of a set of records is a table.
SQL can be used by a range of user including DBAs application programmers , management personal , and many other types of end users.
SQL Provides command for a variety of tasks including:
querying data
Inserting, updating and deleting rows in a table
Creating, modifying and deleting database objects
controlling access to the database and database objects
guaranteeing database consistency.
The American National Standards Institute (ANSI) adopted as the standard language for RDBMSs in 1986. The International Standards Organization (ISO) has also-------
The SQL Commands SetCommands
SELECT
INSERT
UPDATE
DELET
CREATE
ALTER
DROP
GRANT
REVOKE
Description
This is the most commonly used command: it is used to retrieve data from the database
These three commands are used to enter new rows. Change existing rows and remove unwanted rows form tables in the database respectively (They are sometimes collectively know as DML or Data Manipulation Language commands
These three commands are used dynamically to set up. Change and remove any data structure for example, tables, views , indexes . (They are sometimes collectively know as DDL or Data Definition Language commands.)
These two commands are used to save or remove access rights to both the Oracle database and the structures within it
Writing SQL Commands When writing SQL commands , it is important to remember a few simple rules and guidelines in order to construct valid statements that are easy to read and edit:
•SQL commands may be on one or many lines.
•Clauses are usually placed on separate.
•Tabulation can be used.
•Command words cannot be split across lines.
•SQL commands are not case sensitive.
•An SQL command is entered at the SQL prompt, and subsequent lines are numbered. This is called the SQL buffer.
•Only one statement can be current at any time within the buffer and it can be run in a number of ways:
-Place a semi-colon(:) at the end of last clause.
- Place a semi-colon/forward slash on the last line in the buffer.
The data types that a cell can hold
CHAR
VARCHAR (size)
VARCHAR2 (size)
LONG VARCHAR
NUMBER
DATE
LONG
RAW/ LONG RAW
The Create Table Command:Syntax:
CREATE TABLE table name
(columname datatype(size) , columname datatype(size);
Example:
Create a client_master table who structure is:
Column Name
Data Type
Size
Client_no
Name
Address
City
State
Pincode
Remarks
Bal_due
varchar2
varchar2
varchar2
varchar2
varchar2
number
varchar
Number
6
20
30
15
15
6
60
10,2
CREATE TABLE client_master
(client_no varchar2(6),name varchar2(20),address varchar2(30),city varchar2(15),state varchar2(15),pincode number(6),remarks varchar2(60),bal_due number(10,2));
Self review Questions:Read the questions and write down appropriate SQL statements, as answer
1) Fill the table below as your choice
2) Describe where may be used your chosen table
3) Gives the name of this table
4) Create the table with appropriate SQL statements.
Column Name
Data Type
Size
Find the error from the following SQL statements:
CREATE TABLE salesman_master (salesman_no varchar2(6)), salesman_name number(2) state varchar2(20),