You are on page 1of 8

ASSESSMENT 1

Submitted By
PRAVEEN ASHOK DEVIHOSUR
STUDENT ID: 13222620

Task 1: Creating a Database Schema:


Purpose:
Use the CREATE SCHEMA statement to create multiple tables and views and perform multiple grants in your
own schema in a single transaction.
Prerequisites:
The CREATE SCHEMA statement can include CREATE TABLE, CREATE VIEW, and
GRANT statements. To issue a CREATE SCHEMA statement, you must have the privileges necessary to
issue the included statements.
Syntax:
CREATE SCHEMA AUTHORIZATION schema
{ create_table_statement
| create_view_statement
| grant_statement
}...
;

Keywords and Parameters:

SCHEMA:
Specify the name of the schema. The schema name must be the same as your Oracle Database
username.
create_table_statement:
Specify a CREATE TABLE statement to be issued as part of this CREATE
SCHEMA statement. Do not end this statement with a semicolon (or other terminator character).
create_view_statement:
Specify a CREATE VIEW statement to be issued as part of this CREATE
SCHEMA statement. Do not end this statement with a semicolon (or other terminator character).

grant_statement:
Specify a GRANT statement to be issued as part of this CREATE SCHEMA statement. Do not
end this statement with a semicolon (or other terminator character). You can use this clause to
grant object privileges on objects you own to other users. You can also grant system privileges to
other users if you were granted those privileges WITH ADMIN OPTION.

TASK 2:CREATING TABLES AND CONSTRAINTS:


CREATE TABLE:
Purpose:

Use the CREATE TABLE statement to create one of the following types of tables:
A relational table, which is the basic structure to hold user data.
An object table, which is a table that uses an object type for a column
definition. An object table is explicitly defined to hold object instances of a
particular type.
You can also create an object type and then use it in a column when creating a
relational table.
Tables are created with no data unless a subquery is specified. You can add rows to a
table with the INSERT statement. After creating a table, you can define additional
columns, partitions, and integrity constraints with the ADD clause of
the ALTER TABLE statement. You can change the definition of an existing column or
partition with the MODIFY clause of the ALTER TABLE statement.
Prerequisites

To create a relational table in your own schema, you must have

the CREATE TABLE system privilege.


To create a table in another user's schema, you must have
the CREATE ANY TABLE system privilege. Also, the owner of the schema to contain
the table must have either space quota on the tablespace to contain the table or
the UNLIMITED TABLESPACE system privilege.

relational_properties
The relational properties describe the components of a relational table.
column_definition
The column_definition lets you define the characteristics of the column.
column
Specify the name of a column of the table.
If you also specify AS Subquery, then you can omit column and datatype unless you are
creating an index-organized table. If you specify AS Subquery when creating an indexorganized table, then you must specify column, and you must omit datatype.
The absolute maximum number of columns in a table is 1000. However, when you create an
object table or a relational table with columns of object, nested table, varray, or REF type,
Oracle Database maps the columns of the user-defined types to relational columns, in effect
creating hidden columns that count toward the 1000-column limit.
datatype
Specify the datatype of a column.
Restriction on Table Column Datatypes

You can specify a column of type ROWID but Oracle Database does not guarantee that the
values in such columns are valid rowids.
Table Description:
Table 1: user
This table contains the user details like user_no, user_firstname, user_lastname,
user_phonenumber, user_OrgNo, user_Role.
In user table user_no is the primary key.
Table 2: ExpenseReport
This table contains the ExpenseReport details like ExpRepNo, ExpReportDes,
ExpRepSubmitDate, ExpRepStatusDate, ExpRepStatus, SubmitUserNo, ApprUserNo.
In this table SubmitUserNo is the foreign key referenced by the user table. ExpRepNo is the
primary key.
Table 3: ExpenseCat
Contains data about expense categories in which expense items are associated.
This table contains the information like ExpCatNo, ExpCatName, ExpCatLimit.
In this table ExpCatNo is the Primary key.
Table 4: ExpenseItem
Contains data on the detail lines of expense reports .
This table contains the details ElNo, ExpDesc, ExpDate, ExpAmt,ExpApprAmt,
ExpRepNo, ExpCatNo, AssetNoExpRecID.
In this table ExpCatNo and ExpRepNo are the foreign key referenced by the ExpenseCat and
ExpenseReport tables respectively.
Table 5: Assets
Contains data about company assets that might be associated with expense items.
This table contains details about the assets used in expense report.

It contains AssetNo, and AssetDesc. AssetNo is the primary key constraints


Table 6: OrgUnit
Contains data about the organizational units in which users are members.
It contains the details about org_name, org_no, org_ParentNo.
Table 7: BudgetItem
Contains data about expense budgets by organizational unit and expense category for each
financial year.
Table 8: Log_table
Contains data about exceptional data insertion and update

Task 3 Create a Sequences and Users, Loading data:


Purpose
Use the CREATE SEQUENCE statement to create a sequence, which is a database object from
which multiple users may generate unique integers. You can use sequences to automatically
generate primary key values.
Prerequisites
To create a sequence in your own schema, you must have the CREATE SEQUENCE system
privilege.
To create a sequence in another user's schema, you must have
the CREATE ANY SEQUENCE system privilege.
Syntax:
CREATE SEQUENCE [ schema. ]sequence
[ { INCREMENT BY | START WITH } integer
| { MAXVALUE integer | NOMAXVALUE }
| { MINVALUE integer | NOMINVALUE }
| { CYCLE | NOCYCLE }

| { CACHE integer | NOCACHE }


| { ORDER | NOORDER }
]
[ { INCREMENT BY | START WITH } integer
| { MAXVALUE integer | NOMAXVALUE }
| { MINVALUE integer | NOMINVALUE }
| { CYCLE | NOCYCLE }
| { CACHE integer | NOCACHE }
| { ORDER | NOORDER }
]... ;

Semantics
schema
Specify the schema to contain the sequence. If you omit schema, then Oracle Database creates
the sequence in your own schema.
sequence
Specify the name of the sequence to be created.
If you specify none of the following clauses, then you create an ascending sequence that starts
with 1 and increases by 1 with no upper limit. Specifying only INCREMENT BY -1 creates a
descending sequence that starts with -1 and decreases with no lower limit.

To create a sequence that increments without bound, for ascending sequences, omit
the MAXVALUE parameter or specify NOMAXVALUE. For descending sequences,
omit the MINVALUE parameter or specify the NOMINVALUE.

To create a sequence that stops at a predefined limit, for an ascending sequence, specify a
value for the MAXVALUE parameter. For a descending sequence, specify a value for
the MINVALUE parameter. Also specify NOCYCLE. Any attempt to generate a
sequence number once the sequence has reached its limit results in an error.

To create a sequence that restarts after reaching a predefined limit, specify values for both
the MAXVALUE and MINVALUE parameters. Also specify CYCLE. If you do not
specify MINVALUE, then it defaults to NOMINVALUE, which is the value 1.

INCREMENT BY specify the interval between sequence numbers. This integer value can be
any positive or negative integer, but it cannot be 0. This value can have 28 or fewer digits. The
absolute of this value must be less than the difference of MAXVALUE and MINVALUE. If this
value is negative, then the sequence descends. If the value is positive, then the sequence ascends.
If you omit this clause, then the interval defaults to 1.
START WITH specify the first sequence number to be generated. Use this clause to start an
ascending sequence at a value greater than its minimum or to start a descending sequence at a
value less than its maximum. For ascending sequences, the default value is the minimum value
of the sequence. For descending sequences, the default value is the maximum value of the
sequence. This integer value can have 28 or fewer digits.

You might also like