CodesJava

Easy learning with example program codes

SQL CONSTRAINTS


The SQL constraints are the rules enforced on the data in a table. A constraint can be specified with the CREATE TABLE statement at the time table creation or we can specify it with the ALTER TABLE statement after the table creation.

Syntax:

CREATE TABLE <em>tableName</em>
(
<em>columnName1 datatype</em>(<em>size</em>) <em>constraintName</em>,
<em>columnName2 data_type</em>(<em>size</em>) <em>constraintName</em>,
<em>columnName2 data_type</em>(<em>size</em>) <em>constraintName</em>,
....
);

Commonly used constraints in SQL:

1. SQL PRIMARY KEY Constraint.

2. SQL FOREIGN KEY.

3. SQL NOT NULL Constraint.

4. SQL UNIQUE Constraint.

5. SQL CHECK Constraint

6. SQL DEFAULT Constraint

7. SQL INDEX Constraint.

 
Next Topic: SQL PRIMARY KEY Constraint with example.
Previous Topic: SQL TRUNCATE Table with example.

Related Topics:

How to build java project using ant in eclipse?
JAXB marshalling – convert java object to xml example.
How to create pdf file in java using iText jar?
Generics class example.
OGNL in struts 2.
Hibernate One-to-One Mapping using xml.
Send inline image in email using JavaMail API.
Quartz 2 JobListener example.

 



Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki