Download Oracle WebServer User's Guide

Transcript
scott.Customers.LNAME
You can simplify references like this by using synonyms, which are aliases for
tables or other database objects. Synonyms can be private, meaning that they are
part of your schema and you control their usage, or public, meaning that all users
can access them. For example, you can create a synonym “Cust” for
scott.Customers as follows:
CREATE SYNONYM Cust FOR scott.Customers;
This would be a private synonym, which is the default. Now you could rewrite
the example above like this:
Cust.LNAME
You still have to refer to the column directly. Synonyms can only be for tables,
not table components like columns.
For more information on synonyms, see “CREATE SYNONYM” in Chapter 4 of
the Oracle7 Server SQL Reference. For more information on SQL naming
conventions, see Chapter 2 of the Oracle7 Server SQL Reference. For more on
schemas, see “CREATE SCHEMA” in Chapter 4 of the Oracle7 Server SQL
Reference.
Inserting and Manipulating the Data
Which SQL statements determine the actual data content? Chiefly, three —the
INSERT statement, the UPDATE statement, and the DELETE statement. INSERT
places rows in a table, UPDATE changes the values they contain, and DELETE
removes them.
The INSERT Statement
For INSERT, you simply identify the table and its columns and list the values, as
follows:
INSERT INTO Customers (cnum, FNAME, LNAME)
VALUES (2004, ’Harry’, ’Brighton’);
This statement inserts a row with a value for every column but ADDRESS. Since
you did not, in your CREATE TABLE statement, place a NOT NULL constraint
on the ADDRESS column, and since you did not give that column a value here,
Oracle sets this column to null. If you are inserting a value into every column of
the table, and you have the values ordered as the columns are in the table, you
can omit the column list. You optionally can put a SELECT statement in place of
the VALUES clause of the INSERT statement to retrieve data from elsewhere in
the database and duplicate it here. For more information on the INSERT and the
B-8
Oracle WebServer 2.0 User’s Guide