Category: SQL

DELETE Statement in SQL

To delete a record from a table, we make use of DELETE statement.  After deleting a record, you can’t undo it.  If you want to delete a specific record, please add WHERE clause to it.  Syntax for DELETE statement is given below.   Delete All Records: DELETE * FROM {Table_Name} Delete Specific Record: DELETE *

WHERE Clause in SQL

In SQL, you can fetch, update, and delete records in a table when a certain condition is met.  For this reason, we use WHERE clause. The most commonly used operators with WHERE clause are given below. Equal (=) Not Equal (<> or !=) Greater than (>) Less than (<) Greater than or Equal (>=) Less

SELECT Statement in SQL

SELECT statement in SQL helps to fetch data from a table.  That data selection can be from specific columns or all columns in a table which is stored in a table called result-set.  Syntax for SELECT statement is given below.   By Columns Name: SELECT column_name1,column_name2, column_name3 FROM table_name; All Columns: SELECT * FROM table_name;

Dropping Constraint in SQL

We have seen in previous tutorials how to add constraints like FOREIGN KEY and DEFAULT.  But in case, you no longer need them, then you can easily drop them using DROP CONSTRAINT statement.  The syntax for dropping a constraint is given below. ALTER TABLE {Table_Name} DROP CONSTRAINT {Constraint_Name}

Default Constraint in SQL

As we have seen in previous tutorial that we can have non-nullable columns in SQL by using NOT NULL constraint.  But if we would not use NOT NULL constraint and insert values in all other columns except to a nullable column, then that column will have null value by default in it.  To overcome this