|

Create Oracle Database Table and Specify Some Constraints

The following are the main constraints which can be defined when you are creating a TABLE. I will be using the ORACLE DBMS .

  • Primary key – The primary key of the table to be created.
  • Foreign key – The primary key of some other table which is being referenced in this table to be created. (The other table should already exist with the column being referenced before calling it in this creation statement)
  • Unique – unique (for candidate keys)
  • Required (NOT NULL) – No Null Values are allowed
  • Check – The column should be some specified createria –

and you can either place the contrainst specification as either :

  • External: after column definitions
  • Inline: same line as a column definition

All of these constraints can be external or inline in Oracle. Typically required (NOT NULL) constraints are inline and others are external.

Here is a basic TABLE creation syntax in Oracle

Here is the table created with the specified constraints

oracle-table-creation-syntax

 

Want more information like this?

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *