One of the most frustrating and time-consuming aspects of database administration, particularly for the novice DBA, is finding the proper command to accomplish a particular task. In Table 13.1, we have listed most common database administration tasks along with the SQL commands used to accomplish these tasks. The detailed syntax of each command is listed later in this chapter.
If You Want to... |
Use This Command |
Add a column/integrity constraint to a table |
ALTER TABLE |
Add a comment to the data dictionary about a column |
COMMENT |
Add a comment to the data dictionary about a table or view |
COMMENT |
Add a comment to the data dictionary about a snapshot |
COMMENT |
Add or remove a resource limit to or from a profile |
ALTER PROFILE |
Add/drop/clear redo log file group members |
ALTER DATABASE |
Add/rename datafiles |
ALTER TABLESPACE |
Allocate an extent for a cluster |
ALTER CLUSTER |
Allocate an extent for the table |
ALTER TABLE |
Allow/disallow writing to a table |
ALTER TABLE |
Allow/disallow writing to a tablespace |
ALTER TABLESPACE |
Back up the current control file |
ALTER DATABASE |
Begin/end a backup |
ALTER TABLESPACE |
Bring a rollback segment online/offline |
ALTER ROLLBACK SEGMENT |
Change a rollback segment’s storage characteristics |
ALTER ROLLBACK SEGMENT |
Change a snapshot log’s storage characteristics |
ALTER SNAPSHOT LOG |
Change a user’s default role |
ALTER USER |
Change a user’s default tablespace |
ALTER USER |
Change a user’s password |
ALTER USER |
Change a user’s profile |
ALTER USER |
Change a user’s tablespace quotas |
ALTER USER |
Change a user’s temporary tablespace |
ALTER USER |
Change default storage characteristics |
ALTER TABLESPACE |
Change the authorization needed to access a role |
ALTER ROLE |
Change a snapshot’s storage, refresh time, or refresh mode |
ALTER SNAPSHOT |
Change the name of a database |
CREATE CONTROL FILE |
Change the name of a schema object |
RENAME |
Change the storage characteristics of a cluster |
ALTER CLUSTER |
Choose archivelog/noarchivelog mode |
ALTER DATABASE |
Choose auditing for specified SQL commands |
AUDIT |
Choose auditing for operations on schema objects |
AUDIT |
Collect performance statistics for a table, index, or cluster |
ANALYZE |
Convert an Oracle Version 6 data dictionary when migrating to Oracle7 |
ALTER DATABASE |
Create a cluster that can contain one or more tables |
CREATE CLUSTER |
Create a database trigger |
CREATE TRIGGER |
Create a database |
CREATE DATABASE |
Create a directory database object (for BFILEs) |
CREATE DIRECTORY |
Create a library from which to call external 3GL functions and procedures |
CREATE LIBRARY |
Create a link to a remote database |
CREATE DATABASE LINK |
Create a new datafile |
ALTER TABLESPACE |
Create a new database user |
CREATE USER |
Create a new datafile in place of an old one for recovery purposes |
ALTER DATABASE |
Create a place in the database for storage of database objects |
CREATE TABLESPACE |
Create a profile and specify its resource limits |
CREATE PROFILE |
Create a role |
CREATE ROLE |
Create a rollback segment |
CREATE ROLLBACK SEGMENT |
Create a sequence for generating sequential values |
CREATE SEQUENCE |
Create a snapshot log containing changes made to the master table |
CREATE SNAPSHOT LOG |
Create a snapshot of data from one or more remote master tables |
CREATE SNAPSHOT |
Create a stored function |
CREATE FUNCTION |
Create a stored procedure |
CREATE PROCEDURE |
Create a synonym for a schema object |
CREATE SYNONYM |
Create a table and define its columns, constraints, and storage |
CREATE TABLE |
Create an incomplete object type |
CREATE TYPE |
Create an index for a table or cluster |
CREATE INDEX |
Create an object type |
CREATE TYPE |
Create the body of a stored package |
CREATE PACKAGE BODY |
Create the specification of a stored package |
CREATE PACKAGE |
Define a view of one or more tables or views |
CREATE VIEW |
Delete all the rows from a table |
TRUNCATE TABLE or DELETE FROM |
Delete a user from the database |
DROP USER |
Disable auditing by reversing the effect of a prior AUDIT statement |
NOAUDIT |
Enable/disable a database trigger |
ALTER TRIGGER |
Enable/disable a thread of redo log file groups |
ALTER DATABASE |
Enable/disable all triggers on a table |
ALTER TABLE |
Enable/disable autoextending the size of datafiles |
ALTER TABLESPACE |
Enable/disable table locks on a table |
ALTER TABLE |
Enable/disable/drop an integrity constraint |
ALTER TABLE |
Grant system privileges, roles, and object privileges to users and roles |
GRANT |
Identify chained rows for a table, index, or cluster |
ANALYZE |
Issue multiple CREATE TABLE, CREATE VIEW, and GRANT statements |
CREATE SCHEMA |
Modify the degree of parallelism for a table |
ALTER TABLE |
Open/mount the database |
ALTER DATABASE |
Perform media recovery |
ALTER DATABASE |
Prepare to downgrade to an earlier release of Oracle |
ALTER DATABASE |
Recompile a stored function |
ALTER FUNCTION |
Recompile a stored package |
ALTER PACKAGE |
Recompile a stored procedure |
ALTER PROCEDURE |
Recompile a view |
ALTER VIEW |
Recreate a control file |
CREATE CONTROLFILE |
Recreate SQL commands to build the database to the trace file |
ALTER DATABASE |
Redefine a column to change a table’s storage characteristics |
ALTER TABLE |
Redefine an index’s future storage allocation |
ALTER INDEX |
Redefine value generation for a sequence |
ALTER SEQUENCE |
Remove a cluster from the database |
DROP CLUSTER |
Remove a database link |
DROP DATABASE LINK |
Remove a directory object from the database |
DROP DIRECTORY |
Remove a library object from the database |
DROP LIBRARY |
Remove a profile from the database |
DROP PROFILE |
Remove a role from the database |
DROP ROLE |
Remove a rollback segment from the database |
DROP ROLLBACK SEGMENT |
Remove a sequence from the database |
DROP SEQUENCE |
Remove a snapshot from the database |
DROP SNAPSHOT |
Remove a snapshot log from the database |
DROP SNAPSHOT LOG |
Remove a stored function from the database |
DROP FUNCTION |
Remove a stored package from the database |
DROP PACKAGE |
Remove a stored procedure from the database |
DROP PROCEDURE |
Remove a synonym from the database |
DROP SYNONYM |
Remove a table from the database |
DROP TABLE |
Remove a tablespace from the database |
DROP TABLESPACE |
Remove a trigger from the database |
DROP TRIGGER |
Remove a user and the objects in the user’s schema from the database |
DROP USER |
Remove a user-defined type from the database |
DROP TYPE |
Remove a view from the database |
DROP VIEW |
Remove all rows from a table or cluster and free the space that the rows used |
TRUNCATE |
Remove an index from the database |
DROP INDEX |
Rename a datafile/redo log file member |
ALTER DATABASE |
Resize one or more datafiles |
ALTER DATABASE |
Revoke system privileges, roles, and object privileges from users and roles |
REVOKE |
Shrink a rollback segment to an optimal or given size |
ALTER ROLLBACK SEGMENT |
Specify a formula to calculate the total cost of resources used by a session |
ALTER RESOURCE COST |
Take a datafile online/offline |
ALTER DATABASE |
Take a tablespace online/offline |
ALTER TABLESPACE |
Validate structure of a table, index, or cluster |