Chapter6 Thai 9
Chapter6 Thai 9
Chapter6 Thai 9
Object Description
Table Basic unit of storage; composed of rows
View Logically represents subsets of data from one or
more tables
Sequence Generates numeric values
Index Improves the performance of some queries
Synonym Gives alternative name to an object
• You specify:
– Table name
– Column name, column data type, and column size
USERA USERB
SELECT * SELECT *
FROM userB.employees; FROM userA.employees;
• Syntax:
CREATE TABLE [schema.]table
(column datatype [DEFAULT expr]
[column_constraint],
...
[table_constraint][,...]);
Ensures that null values are not permitted for the column:
…
NOT NULL constraint Absence of NOT NULL
(Primary Key enforces NOT NULL constraint (Any row can
NOT NULL constraint.) constraint contain a null value for
this column.)
UNIQUE constraint
EMPLOYEES
…
INSERT INTO
Allowed
Not allowed:
already exists
Not allowed
(50 already exists)
…
EMPLOYEES
FOREIGN
KEY
…
INSERT INTO Not allowed
(9 does not
exist)
Allowed
UPDATE employees
SET department_id = 55
WHERE department_id = 110;
DESCRIBE dept80