0% found this document useful (0 votes)
55 views

Cheat Sheet - DBMS

DDL is used to define database schema by creating, altering, and dropping objects like tables and views. DML allows users to query and manipulate data using commands like select, insert, update, and delete. DCL controls user privileges using grant and revoke. TCL manages transactions with commit and rollback.

Uploaded by

Kaito
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Cheat Sheet - DBMS

DDL is used to define database schema by creating, altering, and dropping objects like tables and views. DML allows users to query and manipulate data using commands like select, insert, update, and delete. DCL controls user privileges using grant and revoke. TCL manages transactions with commit and rollback.

Uploaded by

Kaito
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

DDL – Data Definition Language: Data Definition Language is used to specify the structure i.e.

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.

Scale is the number of digits allowed after the decimal


point. Precision is the total number of significant digits i.e. digits
both before and after the decimal point. If Scale is not provided then
NUMBER datatype can be used to store integral values.

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.

Various constraints that can be created on database tables are:

• 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:

DELETE FROM tableName WHEN X = y;


FILE PROBLEMS:
- only 1 person can modify

WHAT CAN DBMS do?


- STORE/FETCH MODIFY AND DELETE DATA

- USE TRANSACTIONS TO ENSURE DATA CONSISTENCY

- ENSURE DATA INTEGRITY

- ENABLE CONCURRENT ACCESS

- ENSURE DATA RECOVERY

- ENSURE DATA SECURITY

- PROVIDE UTILITIES TO ADMINISTER DATABASE

FLAVORS OF DBMS:

- RELATIONAL DBMS – ORACLE, MYSQL, SQLserver and DB2

- NOSQL – MONGODB, CASANDRA

RELATIONAL DBMS:

- A table is a relationship

- column titles are attributes

- rows are records or tuples

- number of records is the cardinality of relations

- number of attributes is equal to the degree of relations

- a set of values of attributes is called the domain

CANDIDATE KEY:

- a minimal set of columns or attributes that can be used to identify a record/tuple.

- a composite candidate key is a combination of two columns or attributes to find a tuple.

PRIMARY KEY AND UNIQUE KEY:

- PRIMARY KEYS DO NOT ACCEPT NULL VALUES

- UNIQUE KEYS CAN ACCEPT NULLS AND CAN BE MULTIPLE IN NUMBER IN TABLES
FOREIGN KEYS:

- FOREIGN KEYS ALLOW NULL VALUES

HOW TO STORE AND MODIFY DATA IN DB TABLE:

- INSERT INTO tableName VALUES (value1, value2….valueN)

- ALTER TABLE tableNAME ADD nameOFColumn attribute; Attribute = NUMBER, INTEGER etc.

Introduction To SQL Commands:

- LENGTH(COLUMN_Name) gives the character length.

You might also like