0% found this document useful (0 votes)
17 views3 pages

Syntax

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views3 pages

Syntax

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Syntax and queries for each operation.

Syntax explains the general structure, while the query


provides an example based on the database schema:

1. Create Database

Syntax:

CREATE DATABASE database_name;

Query:

CREATE DATABASE UniversityManagement;

2. Use Database

Syntax:

USE database_name;

Query:

USE UniversityManagement;

3. Create Table

Syntax:

CREATE TABLE table_name (


column_name1 data_type constraints,
column_name2 data_type constraints,
...
);

Query (Students Table):

CREATE TABLE Students (


Student_ID VARCHAR(10) PRIMARY KEY,
Student_Name VARCHAR(50),
Date_of_Birth DATE,
Gender VARCHAR(10),
Contact_Number VARCHAR(15),
Address VARCHAR(100)
);

4. Insert Data

Syntax:

INSERT INTO table_name (column1, column2, ...)


VALUES (value1, value2, ...);

Query:

INSERT INTO Students (Student_ID, Student_Name, Date_of_Birth, Gender, Contact_Number,


Address)
VALUES
('S001', 'Alice Johnson', '2005-07-15', 'Female', '1234567890', '123 Elm Street, NY');

5. Select Data

Syntax:

SELECT column1, column2, ...


FROM table_name
WHERE condition;

Query:

SELECT Student_ID, Student_Name FROM Students WHERE Gender = 'Female';

6.Drop Table

Syntax:

DROP TABLE table_name;

Query:

DROP TABLE Students;

7. Retrieve All Data

Syntax:
SELECT * FROM table_name;

Query:

SELECT * FROM Students;

8. Update Data

Syntax:

UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;

Query:

UPDATE Students
SET Contact_Number = '9999999999'
WHERE Student_ID = 'S001';

9. Delete Data

Syntax:

DELETE FROM table_name


WHERE condition;

Query:

DELETE FROM Students


WHERE Student_ID = 'S003';

You might also like