Download presentation
Presentation is loading. Please wait.
1
Database Languages
2
Introduction 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.
3
Introduction SQL statements commonly used in Oracle and MS Access can be categorized as Data Definition Language (DDL) Data Control Language (DCL) Data Manipulation Language (DML).
4
DDL It is a language that allows the users to define data and their relationship to other types of data. It is mainly used to create files, databases, data dictionary and tables within databases. It is also used to specify the structure of each table, set of associated values with each attribute, integrity constraints, security and authorization information for each table and physical storage structure of each table on disk.
5
DDL Commands Create Alter Drop
6
Create Syntax: Example:
Create table table_name(attribute1 data type,….attribute n data type); Example: Create table student(id number, name varchar2(10), id varchar2(10));
7
Alter - add Syntax: Example:
Alter table table_name add(attribute datatype); Example: Alter table student add(phno number);
8
Alter- drop Syntax: Example: Alter table table_name drop(attribute);
Alter table student drop(phno);
9
Drop Syntax: Drop table_name; Example: Drop student;
10
Try to solve..
11
DML commands Create Select Update Insert Delete
12
DML commands It is a language that provides a set of operations to support the basic data manipulation operations on the data held in the databases. It allows users to insert, update, delete and retrieve data from the database. The part of DML that involves data retrieval is called a query language.
13
create SQL > Create Table Cust(cname varchar2(15),cid number(5),caddr char(10), caccno number(5),cacctype varchar2(10),cbalance float, Primarykey(cid),unique(cname),unique(caccno),check(cbalance>=1000)); SQL> desc cust; Name Null? Type CNAME VARCHAR2(15) CID NOT NULL NUMBER(5) CADDR CHAR(10) CACCNO NUMBER(5) CACCTYPE VARCHAR2(10) CBALANCE FLOAT(126)
14
select SQL> select * from cust; CNAME CID CADDR CACCNO CACCTYPE CBALANCE Anusha 1 Chennai 1001 savings Shriram 2 Pondy 1002 savings Chamundi 3 Salem 1003 fd Madhan 4 Salem 1004 checkings 5000 Subha 5 Trichy 1005 checkings Jayashree 6 Pondy 1006 fd Sridharan 7 Kanchi 1007 fd rows selected.
15
update SQL>update cust set caccno=1111 where cname='Chamundi';
1 row updated SQL> select * from cust; CNAME CID CADDR CACCNO CACCTYPE CBALANCE Anusha Chennai savings Shriram Pondy savings Chamundi Salem fd Madhan Salem checkings 4 rows selected.
16
insert SQL> insert into cust values('Anitha',01,'Chennai',1001,'savings',15000); 1 row created. SQL> insert into cust values('Shriram',02,'Pondy',1002,'savings',25000);
17
delete SQL>delete from cust where cacctype='fd'; 3 row deleted
SQL> select * from cust; CNAME CID CADDR CACCNO CACCTYPE CBALANCE Anusha Chennai savings Shriram Pondy savings Madhan Salem checkings Subha Trichy checkings 4 rows selected.
18
Try to solve…
19
DCL commands Grant Revoke
20
DCL Commands DCL statements control access to data and the database using statements such as GRANT and REVOKE. A privilege can either be granted to a User with the help of GRANT statement. The privileges assigned can be SELECT, ALTER, DELETE, EXECUTE, INSERT, INDEX etc. In addition to granting of privileges, you can also revoke (taken back) it by using REVOKE command.
21
Grant Grant < database_priv [database_priv…..] > to <user_name> identified by <password> [,<password…..]; Grant <object_priv> | All on <object> to <user | public> [ With Grant Option ];
22
Revoke Revoke <database_priv> from <user [, user ] >;
Revoke <object_priv> on <object> from < user | public >;
23
Try to solve..
24
Summary In practice, the data definition and data manipulation languages are not two separate languages. Instead they simply form parts of a single database language such as Structured Query Language (SQL). SQL represents combination of DDL and DML, as well as statements for constraints specification and schema evaluation.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.