Tải bản đầy đủ (.pdf) (18 trang)

Tài liệu summary of SQL and SQL plus docx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (104.24 KB, 18 trang )

Summary of SQL and SQL*Plus
17
Introduction to Oracle: SQL and PL/SQL Using Procedure Builder17Ć2
Column
Table
Foreign Key
Row
Primary Key
Summary of SQL and SQL*Plus 17Ć3
Summary of SQL and SQL*Plus
The SQL and SQL*Plus module of the Introduction to Oracle course covered
relational database concepts, the SQL command language, and SQL*Plus commands
to execute and format SQL commands.
Database Terminology
Concept
Description
Table A table is the basic storage structure of an RDBMS, consisting
of one or more columns and zero or more rows.
Row A row is a combination of column values in a table; for
example, the information about one department in the table
S_DEPT. A row is sometimes called a “record.”
Column A column represents one kind of data in a table; for example,
the department name in the example table S_DEPT. It is
described with a column name and holds data of a specific type
and size.
Field At the intersection of a row and a column, you find a field. The
field can contain data. If there is no data in the field, it is said to
contain a null value.
Primary key A primary key is the column or set of columns that uniquely
identifies each row in a table; for example a department
number. It must contain a value.


Foreign key A foreign key is a column or set of columns that refers to a
primary key in the same table or in another table. You create
them to enforce relational database design rules.
Introduction to Oracle: SQL and PL/SQL Using Procedure Builder17Ć4
Summary of SQL and SQL*Plus 17Ć5
Summary of SQL and SQL*Plus
continued
Structured Query Language, SQL*Plus, and PL/SQL commands are used to access
and manipulate data stored in an Oracle database.
SQL*Plus, SQL, and PL/SQL
Language or Tool
Description
SQL A command language for communication with the
Oracle7 Server from any tool or application. Oracle
SQL contains many extensions.
SQL*Plus An Oracle tool that recognizes and executes SQL and
PL/SQL statements and contains its own command
language.
PL/SQL An Oracle procedural language for writing application
logic and manipulating data outside the database.
SQL Commands
There are many commands available in SQL. The table below describes the
commands covered in this course.
Command
Description
SELECT Retrieves data from the database. Most commonly used
command.
INSERT
UPDATE
DELETE

Enters new rows, changes existing rows, and removes unwanted
rows from tables in the database, respectively. Collectively
known as Data Manipulation Language (DML) commands.
CREATE
ALTER
DROP
RENAME
TRUNCATE
Sets up, changes, and removes data structures from tables.
Collectively known as Data Definition Language (DDL)
commands.
COMMIT
ROLLBACK
SAVEPOINT
Manage the changes made by DML statements. Changes to the
data can be grouped together into logical transactions.
GRANT
REVOKE
Gives or removes access rights to both the Oracle database and
the structures within it. Collectively known as Data Control
Language (DCL) commands.
Introduction to Oracle: SQL and PL/SQL Using Procedure Builder17Ć6
Summary of SQL and SQL*Plus 17Ć7
Summary of SQL and SQL*Plus
continued
Oracle Data Dictionary
The data dictionary is a set of tables that the user can access through views. The data
dictionary holds all the data about the database. Whenever the database is in
operation, the data dictionary is updated and maintained by the Oracle7 Server. Write
a SELECT statement to view the contents of the data dictionary views.

The following are some frequently accessed data dictionary tables:
D
DICTIONARY
D
USER_OBJECTS
D
OBJ (alias for USER_OBJECTS)
D
USER_CONSTRAINTS
D
USER_SEQUENCES
SQL*Plus Commands
SQL*Plus commands may be divided into the following main categories:
Category
Purpose
Environment Affects the general behavior of SQL statements for the
session.
Format Formats query results.
File manipulation Saves, loads, and runs script files.
Execution Sends SQL or PL/SQL commands from SQL buffer to
Oracle7 Server.
Edit Modifies SQL commands in the buffer.
Interaction Allows users to create and pass variables to SQL
statements, print variable values, and print messages to
the screen.
Miscellaneous Various commands to connect to the database,
manipulate the SQL*Plus environment, and display
column definitions.

×