by Dinesh Thakur Category: SQL Queries

Constraints are used to limit the type of data that can go into a table. Integrity constraints are used to ensure accuracy and consistency of data in a relational database. Constraints can be specified when a table is created (with the CREATE TABLE statement) or after the table is created (with the ALTER TABLE statement).



 
by Dinesh Thakur Category: SQL Queries

The most difficult part when working with dates is to be sure that the format of the date you are trying to insert, matches the format of the date column in the database. As long as your data contains only the date portion, your queries will work as expected. However, if a time portion is involved, it gets complicated.



 
by Dinesh Thakur Category: SQL Queries

After the table( s) are created and begin to be used, requirements are likely to occur which requires modifications in the structure of the table, such as adding new columns to the table, modifying and existing column's definition etc. So these modifications can be performed using the ALTER table DDL statement. Tills statement changes the structure of the table and not its contents. There are many types of modifications that can be made to the structure of the tables. Using ALTER TABLE statement, you can make modifications such as

 
by Dinesh Thakur Category: SQL Queries

A FOREIGN KEY in one table points to a PRIMARY KEY in another table. On whichever column you put FOREIGN KEY constraint then the values in that column must refer to existing values in the other table.

 
by Dinesh Thakur Category: SQL Queries

Use the LIKE condition to perform wildcard searches of valid search string values. Search conditions can contain either literal characters or numbers. You can combine pattern-matching characters. You can use the ESCAPE identifier to search for the actual % and _ symbols.

 
by Dinesh Thakur Category: SQL Queries

The EXISTS condition is considered "to be met" if the subquery returns at least one row. EXISTS operator simply tests whether the inner query returns any row. If it does, then the outer query proceeds. If not, the outer query does not execute, and the entire SQL statement returns nothing.

 
by Dinesh Thakur Category: SQL Queries

Check constraint is used to validate values entered into a column. CHECK constraints enforce domain integrity by limiting the values that are accepted by a column. They are similar to FOREIGN KEY constraints in that they control the values that are placed in a column. The difference is in how they determine which values are valid: FOREIGN KEY constraints get the list of valid values from another table.

 
by Dinesh Thakur Category: SQL Queries

The PRIMARY KEY constraint uniquely identifies each record in a database table. Primary keys must contain unique values. A primary key column cannot contain NULL values. Each table should have a primary key, and each table can have only one primary key.



 
by Dinesh Thakur Category: SQL Queries

By default all columns in a table can contain null values. If you want to ensure that a column must always have a value, i.e. it should not be left blank, then define a NOT NULL constraint on it.

 
by Dinesh Thakur Category: SQL Queries

A UNIQUE key integrity constraint requires that every value in a column or set of columns (key) be unique-that is, no two rows of a table have duplicate values in a specified column or set of columns.

 

Page 1 of 2

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content