How to Create a Primary Key in Oracle
Here is an example of how to create a primary key in Oracle. The primary key (sample_table_pk) is for the table sample_table. The two column primary key consists of the columns some_string and some_number. ALTER TABLE SAMPLE_TABLE ADD CONSTRAINT SAMPLE_TABLE_PK PRIMARY KEY (SOME_STRING, SOME_NUMBER);
How to Create a Unique Index in Oracle
Here is an example of how to create a unique index in Oracle. The unique index (sample_table_uix) is for the table sample_table. The two columns being indexed are some_string and some_number. CREATE UNIQUE INDEX SAMPLE_TABLE_UIX ON SAMPLE_TABLE ( SOME_STRING ASC, SOME_NUMBER ASC );
How to Create a Non-Unique Index in Oracle
Here is an example of how to create a non-unique index in Oracle. The index (sample_table_ix) is for the table sample_table. The two columns being indexed are some_string and some_date. CREATE INDEX SAMPLE_TABLE_IX ON SAMPLE_TABLE ( SOME_STRING ASC, SOME_DATE ASC );
How to Create a View in Oracle
Here are a couple examples of how to create a view in Oracle. The view has 3 columns (some_string_name, some_number_name, some_date_name) that are sourced from a table called sample_table. Example View 1: CREATE OR REPLACE VIEW SAMPLE_VIEW( SOME_STRING_NAME, SOME_NUMBER_NAME, SOME_DATE_NAME) AS SELECT SOME_STRING, SOME_NUMBER, SOME_DATE FROM SAMPLE_TABLE; Example View 2: CREATE OR REPLACE VIEW SAMPLE_VIEW AS [...]
How to Create a Table in Oracle
Here is an example of how to create a table in Oracle. The table’s name is “sample_table” and has 3 columns. CREATE TABLE SAMPLE_TABLE( SOME_STRING VARCHAR2(50 CHAR), –The “CHAR” part multiplies the precision (50) by 4. This means the storage for the column is 200. SOME_NUMBER NUMBER(32,12), –This column has a total precision of 32, [...]