DBMS Lab
DBMS Lab
2. Persistent Storage: Data remains available and is stored persistently even after the application using it is closed.
3. Efficient Access: Databases are optimized to retrieve and modify data quickly.
5. Security: Databases provide mechanisms for controlling access to data, ensuring privacy and security.
What is Database
CREATE TABLE Student (Rno NUMBER, Name VARCHAR2(50), DOB DATE, Gender CHAR(1),
Class VARCHAR2(20), College VARCHAR2(50), City VARCHAR2(50), Marks NUMBER);
• DESCRIBE TABLE
• Displays the structure of a table (columns and data types).
• Syntax:
DESCRIBE Table_Name;
DML Operations
• INSERT INTO ……
• Adds new rows to the table.
• Syntax:
INSERT INTO TableName (Column1, Column2, ...) VALUES (Value1, Value2, ...);
INSERT INTO Student (Rno, Name, DOB, Gender, Class, College, City, Marks) VALUES (1, 'Aman', TO_DATE('2001-05-12', 'YYYY-MM-
DD'), 'M', '12th', 'ABC College', 'Patiala', 85);
• UPDATE
• Modifies existing records.
• Syntax:
UPDATE TableName SET Column = Value WHERE Condition;
UPDATE Student SET Marks = 89 WHERE Rno = 5;
• DELETE
• Removes rows from the table.
• Syntax:
• DELETE FROM TableName WHERE Condition;
Querying Data
• SELECT Statement
• Retrieves data from the table.
• Syntax:
• SELECT Column1, Column2, ... FROM TableName WHERE Condition;
• ORDER BY Clause
• Sorts the result set.
• Example:
• SELECT * FROM TableName ORDER BY ColumnName ASC;
• Filtering with WHERE
• Filters data based on conditions.
Common Functions and Concepts
• TO_DATE()
• Converts a string to a date format in Oracle.
• Example:
TO_DATE('2025-01-01', 'YYYY-MM-DD');
• Filters
• Use logical operators: AND, OR, NOT.
• Use comparison operators: =, <, >, <=, >=, !=.
• Sorting
• ASC (Ascending), DESC (Descending).