Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Managing Schema Objects ♦ Index

♦ Sequence
♦ Synonym
1. Write the Guidelines for adding columns. ♦ Procedure
♦ We use the ADD clause to add columns ♦ Function
♦ We cannot specify where the column is to
appear 2. Write the guidelines for table & column
♦ The new column becomes the last column names.
Table names and column names:
2. Write the Guidelines for modifying columns. ♦ Must begin with a letter
♦ we can change a column’s data type, size, and ♦ Must be 1-30 characters long
default values. ♦ Must contain only A-Z, a-z, 0-9, _, $ and #
♦ A change to the default value affects only ♦ Must not duplicate the name of another
subsequent insertions to the table. object owned by the same user
♦ Must not be an oracle server-reserved word
3. Write the Guidelines for dropping columns.
We can drop a column from a table by using the 3. What is constraint?
Alter table statement with the drop column Constraints enforce rules at the table level and
clause. prevent the deletion of a table if there are
♦ The column may or may not contain data dependencies from other tables.
♦ Using the ALTER TABLE statement, only one
column can be dropped at a time 4. Write the types of constraint.
♦ The table must have at least one column The following types of constraint are valid-
remaining in it after it is altered. ♦ PRIMARY KEY
♦ After a column is dropped, it cannot be ♦ FOREIGN KEY
recovered. ♦ UNIQUE
♦ A column cannot be dropped if it is part of a ♦ NOT NULL
constraint or part of an index key unless ♦ CHECK
cascade option is added.
♦ Dropping a column can take a while if the 5. Write the names of some data types.
column has a large number of values. There are several data types available in oracle-
♦ VARCHAR2
4. Write the Guidelines for adding constraint. ♦ CHAR
♦ We can add, drop, enable, or disable a ♦ NUMBER
constraint, but we cannot modify its structure.
♦ DATE
♦ We can add a NOT NULL constraint to an
♦ LONG
existing column by using the MODIFY clause of
♦ CLOB
ALTER TABLE statement.
♦ BLOB
♦ BFILE
Manipulating Data ♦ ROWID

1. Write the names of database objects 6. Write the guidelines for creating table by
There are many database objects- using sub query.
♦ Table ♦ The table is created with the specified column
♦ View names, and the rows retrieved by the SELECT
statement are inserted into the table.
♦ The column definition can contain only the
Managing Objects with Data
column name and default value Dictionary Views
♦ If column specifications are given, the
number of columns must equal the number of 1. What is inline view?
columns in the sub query SELECT list. A sub-query in the FROM clause of a SELECT
♦ If no column specifications are given, the statement is called an inline view.
column names of the table are the same as the
column names in the sub query. 2. Why we use sub-queries in DML statement?
♦ The column data type definitions and the We can use sub-queries in DML statements to:
NOT NULL constraint are passed to the new ♦ Copy data from one table to another
table. The other constraint rules are not passed ♦ Retrieve data from an inline view
to the new table. We can add constraints in the ♦ Update data in one table based on the values
column definition. of another table
♦ Delete rows from one table based on rows in
7. Write the uses of Alter table statement a another table
Alter table statement is used to:
♦ Add a new column 3. Write the types of Multi-table INSERT
♦ Modify an existing column statements.
♦ Define a default value for the new column The types of multi-table INSERT statements are-
♦ Drop a column ♦ Unconditional INSERT
♦ Conditional ALL INSERT
8. Write the guidelines for dropping a table. ♦ Conditional FIRST INSERT
♦ All data and structure in the table are deleted ♦ Pivoting INSERT
♦ Any pending transactions are committed
♦ All indexes are dropped 4. Write the restrictions on multi-table INSERT
♦ All constraints are dropped statements.
♦ We cannot roll back the Drop table statement ♦ We can perform multi-table INSERT
statements only on tables, and not on views or
9. Write the guidelines of using Long column materialized views
♦ A long column is not copied when a table is ♦ We cannot perform a multi-table INSERT on a
created using a sub query remote table
♦ A long column cannot be included in a group ♦ We cannot specify a table collection
by or an order by clause. expression when performing a multi-table
♦ Only one long column can be used per table INSERT.
♦ No constraint can be defined on a long ♦ In a multi-table INSERT, all
column insert_into_clauses cannot combine to specify
♦ We might want to use a CLOB column rather more than 999 target columns.
than a long column.
5. Write the uses of MERGE statement.
♦ Merge statement provides the ability to
conditionally update or insert data into a
database table.
♦ Performs an update if the row exists, and an
insert if it is a new row:
♦ Avoids separate updates
♦ Increases performance and ease of use 6. What is an object privilege?
♦ Is useful in data warehousing applications An object privilege is a privilege or right to
perform a particular action on a
specific table, view, sequence, or procedure.
Controlling User Access
7. What is role?
A role is a named group of related privileges
1. What is Privilege? that can be granted to the user.
Privileges are the right to execute particular SQL
statements. 8. Write the names of some object privileges.
Some object privileges are-
2. Write the types of privileges. ♦ Select
There are two types of privileges- ♦ Insert
♦ System privileges ♦ Update
♦ Object privileges ♦ Delete
♦ Alter
3. What is Schema?
♦ Index
A schema is a collection of objects such as
tables, views, Indexes, sequences and synonyms ♦ Execute
♦ References
4. Write the tasks of system privileges.
There are several tasks of system privileges-
♦ Creating new users
♦ Removing users Using DDL Statements to
♦ Removing tables
♦ Backing up tables
Create & Manage Tables
1. What is view?
5. Write the names of system privileges.
A view is a logical table based on a table or
There are more than 100 system privileges such
another view. The advantages of views are-
as-
♦ To restrict data access
♠ DBA system privileges:
♦ To provide data independence
♦ Create user
♦ To make complex queries easy
♦ Drop user
♦ To present different views of the same data
♦ Create any table
♦ Backup any table
2. Write the advantages of views.
♦ Drop any table The advantages of views are-
♦ Select any table. ♦ To restrict data access
♠ User system privileges: ♦ To provide data independence
♦ Create table ♦ To make complex queries easy
♦ Create session ♦ To present different views of the same data
♦ Create sequence
♦ Create view 3. Write the difference between simple and
♦ Create procedure complex views.
There are two classifications for views: simple
and complex. The basic differences between
simple and complex views are following-
♦ A simple view is one that: ♦ Automatically: A unique index is created
♦ Derives data from only one table automatically when we define a
♦ Contains no functions or groups of data primary key or unique constraint in a table
♦ Can perform DML operations through the definition
view ♦ Manually: Users can create nonunique
♦ A complex view is one that: indexes on columns to speed up
access to the rows.
♦ Derives data from many tables
♦ Contains functions or groups of data
9. Write the guidelines for creating index.
♦ Does not always allow DML operations we should create indexes only if-
through the view.
♦ The column contains a wide range of values
4. Write the rules for performing DML ♦ The column contains a large number of null
values
operations on a view.
We can usually perform DML operations on ♦ One or more columns are frequently used
simple views. We cannot remove a row if the together in a where clause or join condition.
view contains the following- ♦ The table is large and most queries are
♦ Group functions expected to retrieve less than 2% to 4% of the
rows.
♦ A group by clause
♦ The DISTINCT keyword
♦ The pseudocolumn ROWNUM keyword

5. What is sequence?
A sequence is a user-created database object
that can be shared multiple users to generate
integers. It can be used to create a primary key
value.

6. Write the guidelines for modifying a


sequence.
♦ We must be the owner or have the Alter
privilege for the sequence
♦ Only future sequence numbers are affected
by the Alter sequence statement ♦ The start
with option cannot be changed using Alter
sequence. The sequence must be dropped and
re-created to restart the sequence at a different
number. ♦ Some validation is performed.
♦ To remove a sequence, drop statement is
used

7. What is Index?
An index is a schema object can be used by the
oracle server to speed up the
retrieval of rows by using a pointer.
8. How are index created?
Indexes are created in two ways-

You might also like