SQL SERVER: commonly used command
|
Command
|
Use To
|
|
CREATE DATABASE
|
Create a new database.
CREATE DATABASE
EmpMaster;
|
|
USE
|
Specify the database to work in.
USE EmpMaster;
|
|
SHOW TABLES
|
Displays a list of tables in a database.
SHOW TABLES EmpMaster;
|
|
CREATE TABLE
|
Add a table to the database and create the attributes for
records to be added to the table.
CREATE TABLE
EmpDetails...
|
|
INSERT INTO
|
Add records to the table. A value must be specified for each
attribute in the table. To leave an attribute blank, place two commas together.
INSERT INTO
EmpDetails VALUES ...
|
|
DESCRIBE
|
See a description of a database object.
DESCRIBE EmpDetails;
|
|
SELECT
|
Retrieve information from a table. Clauses include:
SELECT Name,Address, Salery from EmpDetails...
|
|
WHERE filters using
data from a specified field.
|
|
|
SORT BY sorts
displayed data based on an attribute name.
|
|
|
GROUP BYdetermines how information
in a list is grouped.
|
|
|
UPDATE
|
Change the values in a record.
UPDATE EmpDetails Set
Name='Anil' where EmpId=15;
|
|
DELETE FROM
|
Remove records from a table.
DELETE FROM EmpDetails WHERE
EmpId=15;
|
|
ALTER TABLE
|
Add, change or remove attributes from tables.
ALTER TABLE EmpDetails ADD COLUMN PostCode;
|
|
DROP TABLE
|
Delete an existing table.
DROP TABLE EmpDetails;
|