UNIT - 1 PPT - DBMS - BSC
UNIT - 1 PPT - DBMS - BSC
UNIT - 1 PPT - DBMS - BSC
ARCHITECTURES
Data Model A data model is a collection of
higher level data description
constraints that hides lower level
Types storage details – structure of DB
Defines the basic structure of the database i.e how It is the set of Information stored at a particular
the data will be stored in the database. time.
DBMS architecture and Data
independance
Database Languages
Database languages can be used to read, store and update the data in the
database.
A DBMS must provide appropriate languages and interfaces for each category
of users to express database queries and updates. Database Languages are
used to create and maintain database on computer.
There are large numbers of database languages like Oracle, MySQL, MS
Access, dBase, FoxPro etc.
SQL statements commonly used in Oracle and MS Access can be categorized
as DDL,DML,DCL and TCL.
DB Languages
SQL Statement
CREATE
ALTER COMMIT
DROP SELECT
INSERT ROLLBACK
TRUNCATE GRANT
UPDATE (
RENAME DELETE REVOKE
SAVEPOIN
COMMENT MERGE T)
DDL -It is used to create schema, tables, indexes, constraints, etc. in
the database.
Create: It is used to create objects in the database. Truncate: It is used to remove all records from
◦ Create table tablename(var1/attri datatype, var2 datatype ); a table.
Create table student(regno number , name varchar2(20)); Truncate table tablename;
Truncate table student;
Alter: It is used to alter the structure of the database.
Alter table tablename add attribute datatype; Rename: It is used to rename an object.
Alter table student add phoneno number; Alter table tablename rename column oldname to
Alter table tablename modify attribute datatype; newname;
Alter table student modify regno varchar2(20); Alter table student rename column regno to
Alter table tablename drop column attributename; registernumber;
alter table student drop column name; / alter table student drop
Comment: It is used to comment on the data
name;
dictionary. ( statement will not be executed)
Drop: It is used to delete objects from the database. Single line comments start with --.
Alter table tablename drop column attributename; -- this is example for single line comment
alter table student drop column name; / alter table student drop
Multiline comment start with /* and end with */
name; /* This is example for multiline comment
This statement is not executed */
DML -used for accessing and manipulating data in
a database. It handles user requests.
Select: It is used to retrieve data from a database. Delete: It is used to
◦ Select * from tablename;
Select * from student;
delete all records from a
Insert: It is used to insert data into a table.
table.
◦ Insert into tablename (attribute1, attribute 2) values (value for ◦ Delete table tablename;
attr 1, value for attribu2); / insert into tablename values ( value
Delete table student;
for attr1,value for attr2);
Insert into student(regno,name) values ( 121,’asha’); / insert into ◦ DELETE FROM
values (121,’asha’); table_name WHERE
Update: It is used to update existing data within a table. some_condition;
◦ Update tablename set column2= value2 where condition; Delete from student where
Update student set name= ‘mala’ where regno=121; regno=121;
◦ table_name: name of the
table_name: name of the table
column1: name of first , second, third column....
table
value1: new value for first, second, third column....
condition: condition to select the rows for which the values of ◦ some_condition: condition
MERGE
DCL -used to retrieve the stored or saved data.
The DCL execution is transactional. It also has rollback
parameters. (But in Oracle database, the execution of data
control language does not have the feature of rolling back.)
Syntax:
◦ GRANT privileges ON object TO user;
Object: The name of the database object that you are granting
permissions for. In the case of granting privileges on a table, this
would be the table name.
User: The name of the user that will be granted these privileges.
Privilege Description
ALTER Ability to perform ALTER TABLE statements to change the table definition.
ALL does not grant all permissions for the table. Rather, it grants the ANSI-92
ALL
permissions which are SELECT, INSERT, UPDATE, DELETE, and REFERENCES.
For example, if you wanted to grant SELECT, INSERT, UPDATE, and DELETE
privileges on a table called employees to a user name smithj, you would run the
◦ (ie: SELECT, INSERT, UPDATE, DELETE, and REFERENCES) to a user named smithj.
For example:
If you wanted to grant only SELECT access on the employees table to all users, you
user named anderson, you would run the following REVOKE statement:
If you wanted to revoke ALL ANSI-92 permissions (ie: SELECT, INSERT, UPDATE, DELETE,
and REFERENCES) on a table for a user named anderson, you could use the ALL keyword as
follows:
If you had granted SELECT privileges to the public role (ie: all users) on the employees table
and you wanted to revoke these privileges, you could run the following REVOKE statement:
Syntax:
like save
Save point is quite useful as it divides longer
transactions into smaller parts and marks certain
points of a transaction as checkpoints.
Rollback
TRANSACTION PROPERTIES : ACID
Atomicity − ensures that all operations within the work unit are completed
successfully. Otherwise, the transaction is aborted at the point of failure and all the
Consistency − ensures that the database properly changes states upon a successfully
committed transaction.
other.