Professional Documents
Culture Documents
contents can easily be accessed, managed, and updated. It is an electronic file system
TABLES: a table is a set of data elements (values) that is organized using rows and
columns.
→ Select: The SELECT statement is used to retrieve the data from a database
→ Insert: The INSERT INTO statement is used to insert new records in a table
→ Merge:
→ Alter: The ALTER TABLE statement is used to add, delete, or modify columns in an
existing table/DB
→ Drop: Indexes, tables, and databases can easily be deleted/removed with the DROP
statement
→ Rename:
→ Truncate: if we only want to delete the data inside the table, and not the table itself
→ Commit,
→ Rollback,
→ Savepoint
→ Revoke
→ NOT NULL: If it is imposed on a column that column will not allow null values into it.
It will not occupy any space in the memory. It will not restrict duplicate values.
→ UNIQUE: If it is imposed on a column they will not allow duplicate values. Even it
restricts duplicate values it will allow single null value into the column
→ Primary Key: if we want to restrict null values as well as duplicate values we need o
use primary key. in a table only one PK is allowed
→ Foreign Key: establish a relationship between the data in two tables. FK is created
on the child table. To create FK, the master table should have PK defined on the
common column of the master table. We can have more than 1 FK in a given table
→ Default: the default value for a column if a not null constraint is not presenting on it
is “NULL”, which can be changed by using the ‘default’.
INDEX
DATABASE
1. To create DATABASE
6. To Delete DATABASE
DATABASE:
To create DATABASE
SELECT name
FROM sys.databases
sp_helpdb
USE DB_Name
To Delete DATABASE
drop database DB_Name
TABLES: a table is a set of data elements (values) that is organized using rows and
columns.
To create TABLE
SELECT name
FROM sys.tables
USE mydb
GO
EXEC sp_help
GO
sp_help emp
USE mydb
GO
EXEC sp_help 'emp'
GO