>>-CREATE SCHEMA AUTHORIZATION--user----------------------------> .-------------------------------------------------------------------. V (1) | >----+-| CREATE TABLE Statement |------------------------------------+-+--> | (2) | +-| CREATE VIEW Statement |-------------------------------------+ | (3) | +-| GRANT Statement |-------------------------------------------+ | (4) (5) | '------+-| CREATE INDEX Statement |---------------------------+-' | (6) | +-| CREATE SYNONYM Statement |-------------------------+ | (7) | +-| CREATE TRIGGER Statement |-------------------------+ | (8) (9) | '------+--------| CREATE OPTICAL CLUSTER Statement |-+-' | (10) | +-| CREATE SEQUENCE Statement |---------------+ | (11) | +-| CREATE ROW TYPE Statement |---------------+ | (12) | +-| CREATE OPAQUE TYPE Statement |------------+ | (13) | +-| CREATE DISTINCT TYPE Statement |----------+ | (14) | '-| CREATE CAST Statement |-------------------' >--+---+------------------------------------------------------->< '-;-'
Element | Description | Restrictions | Syntax |
---|---|---|---|
user | User who owns the database objects that this statement creates | If you have DBA privileges, you can specify the name of any user. Otherwise, you must have the Resource privilege, and you must specify your own user name. | Owner Name |
The CREATE SCHEMA statement allows the DBA to specify an owner for all database objects that the CREATE SCHEMA statement creates. You cannot issue CREATE SCHEMA until you have created the database that stores the objects.
Users with the Resource privilege can create a schema for themselves. In this case, user must be the name of the person with the Resource privilege who is running the CREATE SCHEMA statement. Anyone with the DBA privilege can also create a schema for someone else. In this case, user can specify a user other than the person who is running the CREATE SCHEMA statement.
You can put CREATE and GRANT statements in any logical order, as the following example shows. Statements are considered part of the CREATE SCHEMA statement until a semicolon ( ; ) or an end-of-file symbol is reached.
CREATE SCHEMA AUTHORIZATION sarah CREATE TABLE mytable (mytime DATE, mytext TEXT) GRANT SELECT, UPDATE, DELETE ON mytable TO rick CREATE VIEW myview AS SELECT * FROM mytable WHERE mytime > '12/31/2004' CREATE INDEX idxtime ON mytable (mytime);
All database objects that a CREATE SCHEMA statement creates are owned by user, even if you do not explicitly name each database object. If you are the DBA, you can create database objects for another user. If you are not the DBA, specifying an owner other than yourself results in an error message.
You can only grant privileges with the CREATE SCHEMA statement; you cannot use CREATE SCHEMA to revoke or to drop privileges.
If you create a database object or use the GRANT statement outside a CREATE SCHEMA statement, you receive warnings if you use the -ansi flag or set DBANSIWARN.
Related statements: CREATE CAST, CREATE DISTINCT TYPE, CREATE INDEX, CREATE OPAQUE TYPE, CREATE OPCLASS, CREATE ROW TYPE , CREATE SEQUENCE, CREATE SYNONYM , CREATE TABLE , CREATE VIEW , and GRANT
For a discussion of how to create a database, see the IBM Informix Database Design and Implementation Guide.