Cheat Sheet - DBMS
Cheat Sheet - DBMS
schema
of a relational database. DDL provides commands for creation, modification and deletion of various
database objects like tables, views, stored procedures, indexes, constraints etc. The output of DDL is
placed in data dictionary which contains metadata i.e. data about data.
Create
Alter
Drop
Truncate
DML - Data manipulation Language: Data Manipulation Language enables users to access or
manipulate data in a relational database. DML provides commands for retrieval, creation, deletion
and modification of information in a database. DML requires a user to specify what data is needed
without specifying how to get it. The database engine is left to figure out effective means of
retrieving data.
Insert
Update
Delete
Select
DCL – Data Control Language: Data Control Language enables users to provide access to various
database objects like views, tables, stored procedures etc. in a relational database. Typically only
DBAs have access to grant and revoke privileges. Whenever a user submits a query, the database
checks against the granted privileges and rejects the query if it is not authorized.
Control
Revoke
TCL – Tranaction Control Language: Transaction Control Language specifies commands for beginning
and ending a transaction. A transaction consists of a sequence of SQL statements that are applied in
an atomic (all or none) manner. A commit makes all the changes applied by the transaction
permanent on the database while a rollback undoes all the changed applied by the transaction.
Commit
Rollback
SQL supports two character data types for storing printable and displayable characters. They are
used for storing information like name, city, description etc.
We have learnt that data integrity in database systems is enforced through constraints. These
constraints are typically specified along with the CREATE TABLE statement. Constraints are classified
into different types based on the number of columns they act upon as well as on the way they are
specified.
Table level constraint can be specified after all columns used in the constraint have been defined. It is
not necessary to specify them after all columns in the table are defined. Composite constraints can
only be specified as table level constraints.
• NOT NULL
• PRIMARY KEY
• CHECK
• UNIQUE
• FOREIGN KEY
A column can be given the default value by using DEFAULT option. The data type of column
and default expression must be the same. DEFAULT option can be provided for nullable as well
as NOT NULL attributes. Oracle database does not consider DEFAULT as a constraint.
PRIMARY KEY constraint on a column ensures that the column cannot contain NULL and
duplicate values. We can have only one PRIMARY KEY in a table.
CHECK constraint is used to limit the values that can be specified for a column.
UNIQUE constraint on a column ensures that two rows in a table cannnot have same value in
that column. Unlike Primary Key, UNIQUE constraint allows NULL values. A table can have many
UNIQUE constraints.
TO DELETE:
FLAVORS OF DBMS:
RELATIONAL DBMS:
- A table is a relationship
CANDIDATE KEY:
- UNIQUE KEYS CAN ACCEPT NULLS AND CAN BE MULTIPLE IN NUMBER IN TABLES
FOREIGN KEYS:
- ALTER TABLE tableNAME ADD nameOFColumn attribute; Attribute = NUMBER, INTEGER etc.