1. Basic of database and
SQL commands
Made By:
Krutika Malvi :- 224510307064
Niyati Mandaliya :- 224510307066
2. BASIC OF DATABASE
WHAT IS DATABASE?
A database is a collection of inter-related data.
Data is stored in organized manner so that it is available to many users for different purpose.
3. WHAT IS THE PURPOSE OF DATABASE?
To store data.
To provide an organizational structure for data.
To provide a mechanism for querying, creating, modifiying and deleting data.
It provides data security.
DATABASE MANAGEMENT SYSTEM:-
A database management system is a collection of inter-related data and a set of programs to
manipulate those data.
Data manipulation involves various operation such as storing, modifying, removing and
retrieving data.
In other words, DBMS can be described as –
DBMS = Database + A set of programs
4. Where a Database is referred to as DB and a set of programs is referred to as MS
(Management System).
A database management system is also referred to as a database system only.
APPLICATIONS:-
Banking system
Inventory system
Library system
Railway reservation system
College/University
Hospital management system
Cyber-cafe management system
5. DATA-ITEMS (FIELDS):-
A data-item is a character or group of characters (alphabetic or numeric) with a
specific meaning.
It is also called a data-item.
It is represented in the database by a value.
For example, customer id, name, city all are fields for the customer.
RECORD:-
A record is a collection of a logically related fields.
Each field in a record contains a fixed size and data type.
For example, a collection of fields – id, name, city – forms a record for the customer.
A record consists of values for each fields.
6. Database
FILES:-
A file is a collection of related records.
These records are generally arranged in a specific sequence.
File File
File
Record Record Record
Field Field Field
7. Introduction to SQL:
What is SQL?
SQL is a Structured Query Language, is a domain-specific language designed for
managing and query relational databases.
It is relatively easy to learn
Basic command set has vocabulary of less than 100 words
Nonprocedural language
American National Standards Institute (ANSI) prescribes a standard SQL
Several SQL dialects exist
8. SQL commands can be categories into five main types:
1.DATA DEFINITION LANGUAGE:
-Create database objects, such as tables, indexes and
views ,alter, truncate and drop.
-Define access rights to those database objects.
2.Data Manipulation Language:
-Includes commands to insert , update, delete.
3.Data Control Language:
-Used to control the data stored in database.
-includes grant and revoke.
4.Transection Control Language:
-Performs the task of a transection.
-Include commit, save point and rollback.
5.Data Query Language:
-In order to see the present data.
-Includes select.
9. Data Definition Language:
CREATE:- To create the table
Syntax:
CREATE TABLE table_name
(column name 1 datatype
(size), column name 2 datatype
(size), column name n datatype
(size));
Example:
CREATE TABLE std_info (std_id
number (10) primary key,
std_name varchar(15),
std_branch varchar (10));
Output: Table Created.
10. ALTER: To alter table in SQL
Syntax:
ALTERTABLE table_name ADD column_name
datatype (size);
Example:
ALTER TABLE std_info ADD sem number(3);
Output: Table Altered.
11. TRUNCTE: To remove all the rows from the
table.
Syntax:
TRUNCATE TABLE table_name;
Example:
TRUNCATE TABLE std_info;
Output: Table Truncated.
12. DROP: To remove on existing table.
Syntax:
DROP TABLE table_name;
Example:
DROP TABLE std_info;
Output: Table Dropped.
13. Data Manipulation Language:
INSERT: To insert rows into an
existing table / data in a table.
Syntax:
INSERT INTO table_name
(columnName N) values (value 1,
value2, value N);
Example:
INSERT into std_class values
(001,’Niyati’);
Output: 1 Row Inserted.
14. UPDATE: To modify the data in existing table.
Syntax:
UPDATE table_name SET column_name= value
where condition;
Example:
UPDATE std_class SET std_name=‘Krutika’
where std_no=001;
Output: 1 Row Updated.
15. DELETE: To remove single or a multiple
records from the existing table that is known
as delete.
Syntax:
DELETE from table_name where condition;
Example:
DELETE from std_class where std_no=001;
Output: 1 Row Deleted
16. Data Control Language:
It is use to control access to data which
are stored in database.
GRANT:
Syntax:
GRANT privilege_list ON object_name
TO user_name [with GRANT option];
Example:
GRANT ALL ON std_info TO XYZ WITH
GRANT OPTION;
Output: Grant succeeded
17. REVOKE: Cancel previously granted or a
denied permission.
Syntax:
REVOKE privilege_list ON object_name FROM
user_name;
Example:
REVOKE ALL ON SYSTEM std_info from xyz;
Output: Revoke Succeded.
18. Transection Control Language:
COMMIT: Commiting a transection. It can be
commit by either explicity or implicity.
1.Explicit Commit: It makes all change
permanent made during the transaction.
Syntax and Example:
Commit;
Output: Commit Completed.
2.Implicit Commit: Some
operation which forces a
commit to occure
automatically even user don’t
specify to commit command.
19. ROLLBACK: Cancelling a transection.
Syntax & Example:
Rollback;
SAVEPOINT: Cancelling a transection
partially. Used to terminate the current
transection portal.
Syntax:
ROLLBACK TO SAVEPOINT
Savepoint_name;
Syntax:
Savepoint Savepoint_name;
Output: Rollback Completed.
Output: Save point Created.
20. Data Query Language:
SELECT:
Syntax:
SELECT* from table_name;
Example:
SELECT* from std_class;
Output:
S_Name S_Roll no
A 01
B 02