Blog

SQL DROP INDEX, DROP TABLE, and DROP DATABASE
SQL DROP INDEX, DROP TABLE, and DROP DATABASE Indexes, tables, and databases can easily be deleted/removed with the DROP statement. The DROP INDEX Statement The DROP INDEX statement is used to delete an index in a table. DROP INDEX Syntax for MS Access: DROP INDEX index_name…[ More ]
SQL CREATE INDEX Statement
SQL CREATE INDEX Statement The CREATE INDEX statement is used to create indexes in tables. Indexes allow the database application to find data fast; without reading the whole table. Indexes An index can be created in a table to find data more quickly and efficiently. The users c…[ More ]
SQL DEFAULT Constraint
SQL DEFAULT Constraint SQL DEFAULT Constraint The DEFAULT constraint is used to insert a default value into a column. The default value will be added to all new records, if no other value is specified. SQL DEFAULT Constraint on CREATE TABLE The following SQL creates a DEFAULT constr…[ More ]
SQL CHECK Constraint
SQL CHECK Constraint SQL CHECK Constraint The CHECK constraint is used to limit the value range that can be placed in a column. If you define a CHECK constraint on a single column it allows only certain values for this column. If you define a CHECK constraint on a table it can limit th…[ More ]
SQL FOREIGN KEY Constraint
SQL FOREIGN KEY Constraint SQL FOREIGN KEY Constraint A FOREIGN KEY in one table points to a PRIMARY KEY in another table. Let's illustrate the foreign key with an example. Look at the following two tables: The "Persons" table: P_Id LastName FirstName Address City 1 Hansen…[ More ]
SQL PRIMARY KEY Constraint
SQL PRIMARY KEY Constraint SQL PRIMARY KEY Constraint 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 o…[ More ]
SQL UNIQUE Constraint
SQL UNIQUE Constraint SQL UNIQUE Constraint The UNIQUE constraint uniquely identifies each record in a database table. The UNIQUE and PRIMARY KEY constraints both provide a guarantee for uniqueness for a column or set of columns. A PRIMARY KEY constraint automatically has a UNIQUE cons…[ More ]
SQL NOT NULL Constraint
SQL NOT NULL Constraint By default, a table column can hold NULL values. SQL NOT NULL Constraint The NOT NULL constraint enforces a column to NOT accept NULL values. The NOT NULL constraint enforces a field to always contain a value. This means that you cannot insert a new record, or…[ More ]
SQL Constraints
SQL Constraints SQL Constraints Constraints are used to limit the type of data that can go into a table. 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). We will focus on the following c…[ More ]
SQL CREATE TABLE Statement
SQL CREATE TABLE Statement The CREATE TABLE Statement The CREATE TABLE statement is used to create a table in a database. SQL CREATE TABLE Syntax CREATE TABLE table_name(column_name1 data_type,column_name2 data_type,column_name3 data_type,....) The data type specifies what type of…[ More ]
SQL CREATE DATABASE Statement
SQL CREATE DATABASE Statement The CREATE DATABASE Statement The CREATE DATABASE statement is used to create a database. SQL CREATE DATABASE Syntax CREATE DATABASE database_name CREATE DATABASE Example Now we want to create a database called "my_db". We use the following CREATE…[ More ]
SQL SELECT INTO Statement
SQL SELECT INTO Statement The SQL SELECT INTO statement can be used to create backup copies of tables. The SQL SELECT INTO Statement The SELECT INTO statement selects data from one table and inserts it into a different table. The SELECT INTO statement is most often used to create …[ More ]
SQL UNION Operator
SQL UNION Operator The SQL UNION operator combines two or more SELECT statements. The SQL UNION Operator The UNION operator is used to combine the result-set of two or more SELECT statements. Notice that each SELECT statement within the UNION must have the same number of columns.…[ More ]
SQL FULL JOIN Keyword
SQL FULL JOIN Keyword SQL FULL JOIN Keyword The FULL JOIN keyword return rows when there is a match in one of the tables. SQL FULL JOIN Syntax SELECT column_name(s)FROM table_name1FULL JOIN table_name2ON table_name1.column_name=table_name2.column_name SQL FULL JOIN Example …[ More ]
SQL RIGHT JOIN Keyword
SQL RIGHT JOIN Keyword SQL RIGHT JOIN Keyword The RIGHT JOIN keyword Return all rows from the right table (table_name2), even if there are no matches in the left table (table_name1). SQL RIGHT JOIN Syntax SELECT column_name(s)FROM table_name1RIGHT JOIN table_name2ON table_name1.c…[ More ]
SQL LEFT JOIN Keyword
SQL LEFT JOIN Keyword SQL LEFT JOIN Keyword The LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2). SQL LEFT JOIN Syntax SELECT column_name(s)FROM table_name1LEFT JOIN table_name2ON table_name1.colum…[ More ]
SQL INNER JOIN Keyword
SQL INNER JOIN Keyword SQL INNER JOIN Keyword The INNER JOIN keyword return rows when there is at least one match in both tables. SQL INNER JOIN Syntax SELECT column_name(s)FROM table_name1INNER JOIN table_name2ON table_name1.column_name=table_name2.column_name PS: INNER JOIN is…[ More ]
SQL Joins
SQL Joins SQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tables. SQL JOIN The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these …[ More ]
SQL Alias
SQL Alias With SQL, an alias name can be given to a table or to a column. SQL Alias You can give a table or a column another name by using an alias. This can be a good thing to do if you have very long or complex table names or column names. An alias name could be anything, but…[ More ]
SQL BETWEEN Operator
SQL BETWEEN Operator The BETWEEN operator is used in a WHERE clause to select a range of data between two values. The BETWEEN Operator The BETWEEN operator selects a range of data between two values. The values can be numbers, text, or dates. SQL BETWEEN Syntax SELECT column…[ More ]