|

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

  • | | | |

    Free Entity Relationship and Relational Schema Diagram Tool

    ERDPLUS One tool I generally use when working on a projects, mini tasks and exploration is the ERDPLUS tool . It is quite simple and easy to use. It is a Free tool as well. Below are some diagrams I generated when i first got in contact with with tool. ERD DIAGRAMS: 1. 2.  A…

  • | |

    How To Use ER Assistant – FREE Entity Relationship Diagram (ERD) Creation Tool

    There are a lot of ER Diagram Tools. However, by far, one of the favourite ones I use is the ER Assistant which is also free. You can download the ER Assistant free software from here: ER Assistant Download. Install the program after download. In this post, we will learn how to Create Entities Create…

  • |

    SQL Statement Query Clause Evaluation Order – Which Part of SQL Statements Execute First and in What Order?

    Which Part of SQL Statements Execute First and in What Order. It is very important to understand which parts of the SQL Statement executes first and which part comes next until full completion. The diagram below gives an overview of the execution order. The steps in which the SQL statement is executed are as below:…

  • |

    Creating Oracle PL/SQL Tables for Intercollegiate Athletic Database – Data Warehousing

    Creating Oracle  tables for Intercollegiate Athletic Database. Part of Assignment one of Data Warehousing for Business Intelligence on Coursera

    After creating the tables lets insert values

      In case you want to change a constraint on a field, you can use a syntax examples as the following. ALTER TABLE FACILITY ADD CONSTRAINT UNQ_FAC UNIQUE (FACNAME)…

  • | |

    Entity Relationship Diagram – ERD and Cardinality Symbols Simple Explanations

    Understading cardinality notation and being able to explain them will go a long way in your database design and implementation. Here we look at a simple explanation of the symbols. (Credit to Data Warehousing for Business Intelligence by University of Colorado System on Coursera) Symbols in the above diagram and their meanings: – Oval: means 0 –…

Leave a Reply

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