Follow us: Connect on YouTube Connect on YouTube Connect on YouTube


Monday, 11 September 2017

Create SQL Table With Constrains

Constraints are always attached to a column not a table.
We can add constraints in three ways.
Column level -- Along with the column definition
Table level     -- After the table definition
Alter level      -- Using alter command
While adding constraints you need not specify the name but the type only, oracle will internally name the constraint.
If you want to give a name to the constraint, you have to use the constraint clause.

Create table with Constrains with Example:

   empno       NUMBER PRIMARY KEY,
   ename       VARCHAR2 (50) NOT NULL,
   job         VARCHAR2 (10),
   mgr         NUMBER,
   hiredate    DATE DEFAULT (SYSDATE),
   sal         NUMBER,
   hrly_rate   NUMBER,
   comm        NUMBER,
   deptno      NUMBER NOT NULL 
Note: To know more about constrains >SQL Constraints
Share this article :


  1. Hi There,

    Zoooooooom! That’s how speedy and easy this read was! Looking forward to more of such powerful content on Create SQL Table With Constrains.

    I need your help please, I am new at PL/SQL

    I need to run a select command with multiple values, if a break down this query into 3 pieces and run them,they works perfectly, but Ive got problems whenever i execute this query because there are multiple values into the where clause and i think its necessary to create lines break so it may work perfectly

    how can I get through this?

    SELECT job_name, command,description,days_of_week,start_mins,machine, J2.CREATE_STAMP, J2.MODIFY_STAMP
    ON (JR.JOID = J2.JOID)
    WHERE job_name IN ('coscl_PM_zip_log','coscl_PM_clear_log','coscl_PM_alarma_fs','coscl_PM_pmapp1_PM_up','coscl_PM_control_recargas_cod_11','coscl_PM_control_recargas_ingreso','coscl_PM_control_rec_error_cc_agrup_v1'.'coscl_PM_control_procesos_diarios','coscl_PM_rep_recar_x_estado','coscl_PM_control_tiempos_recargas',
    'coscl_PM_control_porcentaje','coscl_PM_control_puertos_bloq','coscl_PM_control_errores', 'coscl_PM_control_java','coscl_PM_control_error_cache');
    Thank you very much and will look for more postings from you.


  2. Hello There,

    I learnt so much in such little time about Create SQL Table With Constrains. Even a toddler could become smart reading of your amazing articles.
    I have requirement like

    select COL1,Col2 from A
    Select COL1,COL2 from B;

    both tables have 50+ millions record so I want to automate a job which will execute this query for 1millions records for one time and then again 1 millions for second loop and store output in record type.

    But nice Article Mate! Great Information! Keep up the good work!

    Kind Regards,