M-2 (2) RDBMS
M-2 (2) RDBMS
INDEX
Creating an Index:
Removing an Index:
• On small tables.
SQL FUNDAMENTALS
Structured Query Language (SQL) is used for storing and managing data in relational database
management systems (RDBMS). Almost all RDBMS (MySQL, Oracle, MS Access, etc.) use SQL. It is case-
insensitive and helps in performing different operations on databases.
Syntax:
CREATE DATABASE database_name;
column1 datatype,
column2 datatype,
...
);
Example:
name VARCHAR(100),
age INT,
dept_name VARCHAR(50)
);
Syntax:
Example:
Unlike DROP, it removes only the data, keeping the table intact.
Syntax:
Example:
Syntax:
Example:
RENAME TABLE Student TO Student_Info;
• Rename a column:
• Delete a column:
• Add a constraint:
ALTER TABLE Student ADD CONSTRAINT chk_age CHECK (age >= 18);
Syntax:
Example:
Syntax:
Example:
Example:
It is used to insert or update records in a table based on data from another table.
Syntax:
USING source_table
ON (condition)
Example:
USING NewStudents
ON (Student.student_id = NewStudents.student_id)
Syntax:
Example:
It allows a user to perform specific actions like SELECT, INSERT, DELETE, etc.
Syntax:
Example:
Syntax:
Example:
Syntax:
Example:
Syntax:
Example:
Syntax:
Example:
Example:
Syntax:
Example:
Syntax:
DESCRIBE table_name;
Example:
DESCRIBE Student;
Syntax:
SHOW DATABASES;
SHOW TABLES;
Example:
SHOW DATABASES;
SHOW TABLES;
Syntax:
HELP command_name;
Example:
HELP SELECT;