|
|
Oracle Database Data Definition Language (DDL commands) Commands: To execute Oracle database commands, you need Oracle's username, password and oracle instance name to connect to oracle database. If you haven't got the username, contact database administrator(DBA) and get the relevant privileges. When you are working with a client, you may be provided a development schema to execute all of your datatabase commands or privileges granted to work on all schemas depending upon your data modelling activity. All commands should be executed from sql> prompt and ";" indicates the end of an oracle command. An Oracle database consists of DDL commands, which are useful to create, modify and drop the database objects. In this section, we will try to explain about important database CREATE commands that are used by a data modeller by relating it with our example data. Create Table GENDER_LKP: Create tables statement are used for creating tables by which data is stored permanently in database.
CREATE TABLE GENDER_LKP ( Create Table DEPARTMENT_LKP:
CREATE TABLE DEPARTMENT_LKP ( Create Table EMPLOYEE_DTL:
CREATE TABLE EMPLOYEE_DTL ( How to copy a table with data? As of now, table EMPLOYEE_DTL contains no data. As soon as you load the data into EMPLOYEE_DTL, try the following command. CREATE TABLE EMPLOYEE_DTL_COPY AS SELECT * FROM EMPLOYEE_DTL; How to copy a table with no data? CREATE TABLE EMPLOYEE_DTL_COPY AS SELECT * FROM EMPLOYEE_DTL WHERE 1=2;
How to create a Sequence? This sequence is used to generate unique numbers for the column EMP_DTL_ID
CREATE SEQUENCE SEQ_EMPLOYEE_DTL How to create a Trigger? Whenever a record is inserted into "EMPLOYEE_DTL" table, this trigger selects the next unique number from the sequence "SEQ_EMPLOYEE_DTL" and inserts into the column "EMP_DTL_ID". In our INSERT STATEMENTS example, we have not provided values for the column "EMP_DTL_ID" and inserting values into "EMP_DTL_ID is taken care by sequence and trigger.
CREATE OR REPLACE TRIGGER TRG_SEQ_EMPLOYEE_DTL Create Index, View, Synonym:
CREATE INDEX IND_SSN ON EMPLOYEE_DTL(SSN);
Sample Data Analysis: Continued... |