dcsimg
Database Journal
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Tips Database Forum

» Database Journal Home
» Database Articles
» Database Tutorials
MS SQL
Oracle
DB2
MS Access
MySQL
» RESOURCES
SQL Scripts & Samples
Tips
» Database Forum
» Slideshows
» Sitemap
Free Newsletters:
DatabaseDaily  

By submitting your information, you agree that databasejournal.com may send you databasejournal offers via email, phone and text message, as well as email offers about other products and services that databasejournal believes may be of interest to you. databasejournal will process your information in accordance with the Quinstreet Privacy Policy.

News Via RSS Feed


Database Journal |DBA Support |SQLCourse |SQLCourse2
 

Featured Database Articles

Oracle

Posted Apr 22, 2002

Listen Software's How To: Tables

By David Nishimoto

Creating a Table

CREATE TABLE {table_name}
(
   {field1} VARCHAR2(10),
   {field2} NUMBER(10)
)
PCTFREE  30	
PCTUSED  60
TABLESPACE (tablespace_name)	
STORAGE  	
(	  
   INITIAL integer	  
   NEXT    integer
);

Adding a Primary Constraint

ALTER TABLE {A_TABLE} ADD (
   CONSTRAINT {A_TABLE_PK}
   PRIMARY KEY ({A_TABLE_IDX})
   USING INDEX 
   TABLESPACE {MY_TABLESPACE}
   PCTFREE  10
   STORAGE  
   (
   INITIAL 20K
   NEXT    40K
   )
)

Adding a Foreign Key Constraint

ALTER TABLE (table_name) ADD 
   (      	
   CONSTRAINT (foreign key constraint name)
   FOREIGN KEY 
   (field name )      	
   REFERENCES  primary_table_name	
   (
   primary_table_primary_index_field	
   )

The foreign key references a unique key in the primary table. The relation is a one-to-many relationship.

Rebuilding Indexes

alter index {my_index_idx} rebuild;

Does not drop the constraints



Oracle Archives

Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 




Latest Forum Threads
Oracle Forum
Topic By Replies Updated
Oracle Data Mining: Classification jan.hasller 0 July 5th, 07:19 AM
Find duplicates - Unique IDs Lava 5 July 2nd, 08:30 AM
no matching unique or primary key rcanter 1 April 25th, 12:32 PM
Update values of one table based on condition of values in other table using Trigger Gladiator 3 February 29th, 06:01 PM











×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.