R D B M S: Elation Ata Ase Anagement Ystem

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

R DBM S elation ata ase anagement ystem

Name:
Class:
Section:
Roll No:
----------------------------------------------------- --RDBMS -----------------------------------------------------------------------------------------

BASICS OF RDBMS (SQL)

* What is DBMS?

Ans: DBMS stands for Data Base Management System.

A Database Management System is system software that is used to Create, Maintain and provide
controlled access to the user databases. (OR)

A Database Management System is a process of maintaining the data in the database in a


systematic form.

* What is Data?

“Data” is nothing but “Facts”. (OR)

The actual data stored in the database is called DATA. For example, the student database may
contain data like Student Roll No, Student Name, Student Address, etc….

* What is Database?

Database is known as “collection of Data”. (OR)


An organised collection of logically related data is called Database. The Database may contain the
information about a particular organization or Enterprise. An Organization may be a College, University, Bank,
etc…

* Data v/s Information?

We define the information as data that it would be processed, so the user may easily identify the
data.

 For example, consider the following list of facts.


Rahul 12465 60

Mohan 20518 40

Arun 30198 70

The above data remains useless. We have no idea what the entire data means.

 For example, we will place some data in the context form. Now it is useful data for some users.

Sri Vaishnavi degree College, Rajampet

Name Reg No Percentage

Rahul 12465 60

Mohan 20578 40

Arun 30198 70

------------------------------------------------------------------------------------------------------------------------------------------------Page | 2
Designed by S.V.NIKETHAN 8019958900 RDBMS
----------------------------------------------------- --RDBMS -----------------------------------------------------------------------------------------
* Metadata:

Metadata is nothing but data about data. (OR)

The data that describes the properties or characteristic features of other data is called Metadata.

 For example, consider the Metadata for the about student data on listed below.

Data Item Name Type Size Description

Name Alphabetic 20 Student Name

Reg No Numeric 10 Student Reg No

Percentage Numeric 2 Marks Percentage

* RDBMS:

RDBMS stands for Relation Database Management System.

A database that represents data as a collection of tables in which all the data relationships
can be maintained by the actual values in the related tables.

 The Relation Data model was 1st introduced in “1970” by “E.F.Codd.”

* What is SQL?

SQL stands for Structure Query Language.

Basically a Structure Query Language is a non procedural language. i.e.; the user needs to
specify the problem and not the procedure to same it. SQL is a very simple language that can be
learned and maintained easily.

* Procedural Language:

Example:

Having a Railway Reservation from friend.

1. Catch the bus.


2. Go to the Railway Station.
3. Fill the Reservation form.
4. Take ticket.
5. Again catch the bus &
6. Come to home.

* Non procedural Language:

Example:

Get me a Railway Reservation.

------------------------------------------------------------------------------------------------------------------------------------------------Page | 3
Designed by S.V.NIKETHAN 8019958900 RDBMS
----------------------------------------------------- --RDBMS -----------------------------------------------------------------------------------------
* What are the features of SQL?

1. Reduction in Language code.


2. Simplicity in writing code.
3. Skills of writing simple code.
4. Reduction of maintaining software.

* How to start or enter into SQL?

Ans: Go to start menu. Select All programs. In that, select Oracle – OraHome81. Then select Application
Development. Then click on SQL plus option.

Start  All programs  Oracle - OraHome  Application Development  SQL Plus  Enter

An “Oracle SQL Plus” window is open with a small “Logon” textbox. In that, enter “username” as “scott”
and password as “tiger”. Then click on “OK” button.

Now the SQL window is open.

* Different types of SQL Commands or Components of SQL?

Ans: The SQL commands are categorized into different types. They are:

1. DDL  Data Definition Language


2. DML  Data Manipulation Language
3. DQL  Data Query Language
4. DCL  Data Control Language
5. TCS  Transaction Control Statement
6. DAS  Data Audit Statement
1. DDL commands :
DDL commands are used to create, Alter and Delete the Database objects like Table. The
commands are “CREATE”, “ALTER” and “DROP”.
A. CREATE:
This command is used to create a table.
Syntax:
CREATE table <table name> (<colname 1 > <Data type> <size>,
<colname 2 > <Data type> <size>,
. . .
. . .
. . .
<colname n > <Data type> <size>);
Example:

CREATE table student (RNo Number(10),

S.Name varchar2(20),

Sub 1 Number (3),

Sub 2 Number (3),

Sub 3 Number(3),

Sub 4 Number(3),
------------------------------------------------------------------------------------------------------------------------------------------------Page | 4
Designed by S.V.NIKETHAN 8019958900 RDBMS
----------------------------------------------------- --RDBMS -----------------------------------------------------------------------------------------
Sub 5 Number(3),

Sub 6 Number (3));

B.ALTER:

This command contains the THREE commands. They are:

I. ADD
ALTER
II. MODIFY
III. DROP
ADDMODIFYDROP

I.ADD:

This command is used to add a column to the existing table.

Syntax:

ALTER table < table name> ADD <colname> < Data type> < size>);

Example:

ALTER table Student ADD (Total Number (4));

Message: Table ALTER

II.MODIFY:

This command is used to modify the data type or size of the column.

Syntax:

ALTER table < table name> MODIFY <colname> < Data type> < size>);

Example:

ALTER table Student MODIFY (SName varchar2 (30));

Message: Table ALTER

III.DROP:

This command is used to delete a column.

Syntax:

ALTER table < table name> DROP <colname>);

Example:

ALTER table Student MODIFY (SName);

------------------------------------------------------------------------------------------------------------------------------------------------Page | 5
Designed by S.V.NIKETHAN 8019958900 RDBMS
----------------------------------------------------- --RDBMS -----------------------------------------------------------------------------------------
2. DML commands:

DML commands are used to insert, update and delete the data in the database. The commands
used are “INSERT”, “UPDATE” and “DELETE”.

A. INSERT:
This command is used to insert record into the table. This command has Three (3)
syntaxes.
Syntax 1:
INSERT into <table name > values (value 1, value 2 … value n);
Example:

INSERT into Student values ( 1008,’Nikethan’, 60, 77, 86, 98, 99, 91);

Syntax 2:
INSERT into <table name> (colname 1, colname 2 ... colnamen) values (value1, value2...value n);

3. DQL commands:

SQL has only one Query statement. The command used is “SELECT”.

SELECT:

This command is used to retrieve the required data from the database.

Syntax:

SELECT astric (*) from <table name>;

Example:

SELECT * from student;

1.Using SELECT command by using ORDER BY:

This command is used to display the data in ‘Descending order’ & ‘Ascending order’ in the user
specify column name. In this, we have two (2) Syntaxes.

Syntax:
To see data in
SELECT astric (*) from <table name> ORDER BY <colane> DESC;
Descending order
Example:

SELECT * from student ORDER BY Roll No DESC;

Syntax:

SELECT astric (*) from <table name> ORDER BY <colane>; To see data in

Example: Ascending order

SELECT * from student ORDER BY Roll No;

------------------------------------------------------------------------------------------------------------------------------------------------Page | 6
Designed by S.V.NIKETHAN 8019958900 RDBMS
----------------------------------------------------- --RDBMS -----------------------------------------------------------------------------------------
2. Using SELECT command by using GROUP BY:

This command is used to display the specified data in groupwise.

Syntax:

SELECT Colname1, Colname2 from <tale name> GROUP BY <Colname>;

Example:

SELECT Dept No, SUM(SAL) from EMP GROUP BY Dept no;

3. Using SELECT command by applying HAVING:

This command is used to specify the data by the user require condition.

Syntax:

SELECT colname1,colname2 from <table name> GROUP BY <colname> HAVING <condition>;

Example:

SELECT Dept No, SUM(SAL) from EMP GROUP BY Dept no HAVING SUM(SAL) > 15,000;

LIST OF SPECIAL SELECT COMMANDS


1. SELECT UPPER (S.Name) from Student;
This command is used to display the student name in upper case.
2. SELECT LOWER (S.Name) from Student;
This command is used to display the student name in lower case.
3. SELECT CONCAT (‘National’, ‘Integrity’)from dual;
This command is used to combine TWO words.
4. SELECT GREATEST (’06-Jan -09’,’20 – Mar – 09 ) from dual;
This command is used to display the greatest date among TWO above dates.
5. SELECT LTRIM ( ‘Super Computer’,’ Super’) from dual;
This command is used to trim the specified word LEFT side.
6. SELECT RTRIM ( ‘Super Computer’,’ Super’) from dual;
This command is used to trim the specified word RIGHT side.
7. SELECT LPAD (RPAD(‘B.Com’,10,”#’),15,’&’)from dual;
This command is used to display the LEFT padding symbols & RIGHT padding symbols specified by
the user.
8. SELECT LAST_DAY(05-Jan-09) from dual;
This command is used to LAST DAY in the specified date.
9. SELECT MONTHS_BETWEEN(’09-Jan-10’)from dual;
This command is used to display the no. of months between the specified date.
10. SELECT POWER(2,5)from dual;
This command is used to display the POWER of specified values.
11. SELECT LENGTH (‘NIKETHAN’)from dual;
This command is used to display the LENGTH of the specified text.
12. SELECT ROUND(8.124)from dual;
This command is used to ROUND the specified text.
13. SELECT SYS_DATE from dual;
This command is used to display the present SYSTEM DATE.
------------------------------------------------------------------------------------------------------------------------------------------------Page | 7
Designed by S.V.NIKETHAN 8019958900 RDBMS
----------------------------------------------------- --RDBMS -----------------------------------------------------------------------------------------
14. SELECT SYS_TIME from dual;
This command is used to display the present SYSTEM TIME.
15. SELECT SQRT (25) from dual;
This command is used to find out SQUARE ROOT of the specified number.

4. DCL commands:

DCL commands is used to manage the data that the manipulation performed by the DML
commands. The DCL commands are “COMMIT”, “ROLLBACK” and “SAVEPOINT”.

A. COMMIT: This command is used to “SAVE” the table.

Ex: COMMIT;

B. ROLL BACK: This command is used to “ROLLBACK” to the specified location.

Ex: ROLLBACK;

C. SAVEPOINT: This command is used to “SAVE” the table in the form of modules.

Ex: SAVEPOINT SP;

5. TCS commands:

TCS commands are used to control the user access to the database. The commands are “GRANT”
and “REVOKE”.

A. GRANT: This command is used ro grant the permission to the user.

Syntax: Grant dba to <username>;

Ex: Grant dba to Nikethan;

B. REVOKE: This command is used to call off (cancel) the permission to the user.

Syntax: REVOKE from <username>;

6. DAS commands:

DAS commands are used to perform auditing. The commands used are “START AUDIT” and “STOP
AUDIT”.

Creation of New user:

1. Enter username as “system”


2. Enter password as “manager”

Now, the SQL window will open.

Type as follows:

SQL> CREATE user Nikethan (username) identified by 143 (password);

user created.

Accessing Permission: SQL> Grant dba to Nikethan;

------------------------------------------------------------------------------------------------------------------------------------------------Page | 8
Designed by S.V.NIKETHAN 8019958900 RDBMS
----------------------------------------------------- --RDBMS -----------------------------------------------------------------------------------------
Message: Permission granted.

Cancelling Permission: SQL> Revoke dba from Nikethan;

Message: Revoke succeed.

------------------------------------------------------------------------------------------------------------------------------------------------Page | 9
Designed by S.V.NIKETHAN 8019958900 RDBMS

You might also like