DROP INDEX
The DROP INDEX
command is used to delete an index in a table.
MS Access:
DROP INDEX index_name ON table_name;
SQL Server:
DROP INDEX table_name.index_name;
The DROP INDEX
command is used to delete an index in a table.
MS Access:
DROP INDEX index_name ON table_name;
SQL Server:
DROP INDEX table_name.index_name;
The DROP DEFAULT
command is used to delete a DEFAULT constraint.
To drop a DEFAULT constraint, use the following SQL:
SQL Server / Oracle / MS Access:
ALTER TABLE Persons
ALTER COLUMN City DROP DEFAULT;
The DROP DATABASE
command is used to delete an existing SQL database.
The following SQL drops a database named “testDB”:
DROP DATABASE testDB;
Note: Be careful before dropping a database. Deleting a database will result in loss of complete information stored in the database!
The DROP CONSTRAINT
command is used to delete a UNIQUE, PRIMARY KEY, FOREIGN KEY, or CHECK constraint.
To drop a UNIQUE constraint, use the following SQL :
SQL Server / Oracle / MS Access:
ALTER TABLE Persons
DROP CONSTRAINT UC_Person;
MySQL:
ALTER TABLE Persons
DROP INDEX UC_Person;
The DROP COLUMN
command is used to delete a column in an existing table.
The following SQL deletes the “ContactName” column from the “Customers” table:
ALTER TABLE Customers
DROP COLUMN ContactName;
The DROP COLUMN
command is used to delete a column in an existing table.
The following SQL deletes the “ContactName” column from the “Customers” table:
ALTER TABLE Customers
DROP COLUMN ContactName;
The SELECT DISTINCT
command returns only distinct (different) values in the result set.
The following SQL statement selects only the DISTINCT values from the “Country” column in the “Customers” table : Continue reading SQL SELECT DISTINCT Keyword
The DESC
command is used to sort the data returned in descending order.
The following SQL statement selects all the columns from the “Customers” table, sorted descending by the “CustomerName” column : Continue reading SQL DESC Keyword
The DEFAULT
constraint provides a default value for a column.
The default value will be added to all new records if no other value is specified.
The following SQL sets a DEFAULT value for the “City” column when the “Persons” table is created:
My SQL / SQL Server / Oracle / MS Access:
CREATE TABLE Persons (
City varchar(255) DEFAULT 'Sandnes'
);
The DEFAULT constraint can also be used to insert system values, by using functions like GETDATE(): Continue reading SQL DEFAULT Keyword
The CREATE DATABASE
command is used is to create a new SQL database.
The following SQL creates a database called “testDB”:
CREATE DATABASE testDB;
Tip: Make sure you have admin privilege before creating any database. Once a database is created, you can check it in the list of databases with the following SQL command: SHOW DATABASES;