Download Chapter 1 : Introduction

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

IMDb wikipedia , lookup

DBase wikipedia , lookup

Tandem Computers wikipedia , lookup

Concurrency control wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Microsoft Access wikipedia , lookup

Btrieve wikipedia , lookup

Entity–attribute–value model wikipedia , lookup

Ingres (database) wikipedia , lookup

Functional Database Model wikipedia , lookup

Microsoft Jet Database Engine wikipedia , lookup

Database wikipedia , lookup

Oracle Database wikipedia , lookup

Null (SQL) wikipedia , lookup

Clusterpoint wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Database model wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Relational model wikipedia , lookup

SQL wikipedia , lookup

PL/SQL wikipedia , lookup

Transcript
Chapter 1 : Introduction
BORDOLOI & BOCK
Bordoloi and Bock
SQL
• SQL, pronounced ‘Sequel’ or simply S-Q-L, is a
computer programming language that was
developed especially for querying relational
databases using a non-procedural approach.
• The term non-procedural means that you can
extract information by simply telling the system
what information is needed without telling how to
perform the data retrieval. The RDBMS parses
(converts) the SQL commands and completes the
task.
Bordoloi and Bock
SQL
• Extracting information from the database by
using SQL is termed querying the database.
• SQL is a language that is fairly simple to learn,
in terms of writing queries but it has
considerable complexity because it is a very
powerful language.
Bordoloi and Bock
DATA AND INFORMATION
• Information is derived from raw facts known as
data.
• Data has little meaning or usefulness to managers
unless it is organized in some logical manner.
• One of the most efficient ways to organize and
manage data is through the use of database
management system (DBMS).
Bordoloi and Bock
DATA
•
Two types of data are stored within a database
•
User data : Data that must de stored by an
organization.
System data: Data the database needs to
manage user data to manage itself. This is
also termed metadata, or the data about data.
•
Bordoloi and Bock
SQL
• Data is manipulated by RDBMS users through
the use of special data manipulation language.
• Database structures can also be defined by the
use of data definition language.
• SQL is the most popular database language and
has commands that enable it to be used for both
manipulation and definition of databases.
Bordoloi and Bock
SQL
•
SQL is used by Oracle for all interaction with
the database. SQL statements fall into the two
major categories
1. Data Definition Language(DDL) : Set of SQL
commands that create and define objects in a
database
2. Data Manipulation Language(DML) : Set of
SQL commands that allow users to
manipulate the data in a database.
Bordoloi and Bock
SQL
• SQL is basically a free format language. This
means that there are no particular spacing rules
that must be followed when typing SQL
commands.
• In Oracle, you must end each individual
SQL statement (irrespective of whether it is
composed as a single or multiple lines of
code) with a semi-colon (;). It is the “;”
which ends an SQL statement and tellls
Oracle to Execute it.
Bordoloi and Bock
RELATIONAL OPERATIONS
• SQL operations for creating new tables,
inserting table rows , updating table rows,
deleting table rows, and querying databases are
the primary means of interfacing with relational
databases.
• The SELECT statement is used primarily to
write queries that extract information from the
database which is a collection of related tables.
Bordoloi and Bock
Starting Oracle SQL*PLUS
•
•
•
The most common types used are either the
standard Oracle SQL*PLUS available for a
Windows-type interface or by connecting to an
Oracle database via a telnet session.
The following Log On session is a connection to
an Oracle database stored on a Sun Microsystems
server running the Unix O/S.
A SQL*PLUS session is begun by typing the
command sqlplus at the command prompt($) and
entering the username and password information .
contd
Bordoloi and Bock
Log On Screen
Bordoloi and Bock
Exiting SQL*PLUS
•
•
The SQL*PLUS session can be ended by
typing a command at the SQL prompt to
terminate the session.
Two commands are available: exit or quit.
Either one of these can be used to terminate a
SQL*PLUS session.
Bordoloi and Bock
Running (Executing) a Command File
•
The command to run (execute) a command file
is:
SQL> START filename.sql
•
A form of shorthand for the word “start” can be
used when executing a command file by
replacing “start” with the @ (“at” symbol).
Bordoloi and Bock
Syntax Conventions
•
•
Each select statement must follow precise
syntactical and structural rules.
The following is the minimum structure and
syntax required for an SQL SELECT statement.
SELECT [DISTINCT | ALL] {* |
select_list}
FROM {table_name [alias] | view_name}
Bordoloi and Bock
SQL Keywords
•
•
Keywords are words that have a predefined
meaning in SQL.
In practice, keywords may be entered in upper
or lower case letters.
SELECT *
FROM employee;
select *
from employee;
Bordoloi and Bock
SQL Keywords
•
•
In some cases keywords can be abbreviated.
The allowed abbreviation is shown in upper
case letters with the remainder shown in lower
case, which means either the full word or only
the upper case part can be used.
DESCribe: can be entered as either DESC or
DESCRIBE.
Bordoloi and Bock
SQL Naming Conventions
•
Identifiers are the names given by information
system developers or system users to database
objects such as tables , columns, indexes, and
other objects as well as the database itself.
• There are several rules for naming database
objects that must be followed.
1. Identifiers should contain between 1 and 30
characters.
2. The first character must be either alphabetic (az, A-Z) or the @ symbol or _ (underscore).
Bordoloi and Bock
SQL Naming Conventions
3. After the first character, digits, letters, or the
symbols $,#, or _(underscore) must be used.
4. No embedded spaces are allowed in identifiers.
5. SQL keywords cannot be used as an identifier.
Bordoloi and Bock