0% found this document useful (0 votes)
1 views

Ansi SQL Using Mysql

The document outlines the key components of ANSI SQL using MySQL, including Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), and Transaction Control Language (TCL). It also covers constraints, SQL operators, functions, clauses, joins, sub-queries, views, and indexes. Each section provides essential commands and concepts necessary for managing and manipulating databases effectively.

Uploaded by

black
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Ansi SQL Using Mysql

The document outlines the key components of ANSI SQL using MySQL, including Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), and Transaction Control Language (TCL). It also covers constraints, SQL operators, functions, clauses, joins, sub-queries, views, and indexes. Each section provides essential commands and concepts necessary for managing and manipulating databases effectively.

Uploaded by

black
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Query - Database / ANSI SQL using MySQL

1. DDL (Data Definition Language)


- CREATE: Used to create tables, databases, indexes, and other objects.
- ALTER: Used to modify existing database structures.
- DROP: Deletes tables, databases, indexes, etc.
- TRUNCATE: Removes all records from a table without logging individual row
deletions.
- RENAME: Changes the name of an existing database object.

2. DML (Data Manipulation Language)


- SELECT: Retrieves data from a database.
- INSERT: Adds new records to a table.
- UPDATE: Modifies existing records in a table.
- DELETE: Removes records from a table.

3. DCL (Data Control Language)


- GRANT: Provides specific privileges to users.
- REVOKE: Removes privileges from users.

4. TCL (Transaction Control Language)


- COMMIT: Saves all changes made by the transaction.
- ROLLBACK: Reverts changes made by the transaction.
- SAVEPOINT: Creates a point in a transaction to which you can later roll back.

5. Understanding Constraints and Their Types


- NOT NULL: Ensures a column cannot have a NULL value.
- UNIQUE: Ensures all values in a column are unique.
- PRIMARY KEY: Uniquely identifies each record in a table.
- FOREIGN KEY: Ensures referential integrity between tables.
- CHECK: Ensures that all values in a column satisfy a condition.
- DEFAULT: Sets a default value for a column if no value is provided.

6. SQL Operators
- Arithmetic Operators: +, -, *, /, %
- Comparison Operators: =, !=, <>, >, <, >=, <=
- Logical Operators: AND, OR, NOT
- Bitwise Operators: &, |, ^, ~, <<, >>

7. SQL Functions
- Aggregate Functions: COUNT(), SUM(), AVG(), MIN(), MAX()
- String Functions: CONCAT(), LENGTH(), UPPER(), LOWER(), SUBSTRING()
- Date Functions: NOW(), CURDATE(), DATE_FORMAT()
- Numeric Functions: ROUND(), CEIL(), FLOOR(), ABS()
- Conversion Functions: CAST(), CONVERT()

8. Clauses in SQL
- WHERE: Filters records based on conditions.
- GROUP BY: Groups records with identical values.
- HAVING: Filters groups based on conditions.
- ORDER BY: Sorts the result set in ascending or descending order.
- LIMIT: Restricts the number of records returned.

9. Joins and Their Types


- INNER JOIN: Returns matching rows from both tables.
- LEFT JOIN: Returns all rows from the left table and matching rows from the
right table.
- RIGHT JOIN: Returns all rows from the right table and matching rows from the
left table.
- FULL OUTER JOIN: Returns all rows when there is a match in either table.
- SELF JOIN: A table joins itself.
- CROSS JOIN: Returns the Cartesian product of both tables.

10. Sub-Queries
- A query nested inside another query.
- Used with SELECT, INSERT, UPDATE, DELETE.
- Can return single or multiple values.

11. Views and Indexes


- View: A virtual table based on a query result.
- Created using CREATE VIEW statement.
- Index: Improves database performance by allowing faster data retrieval.
- Created using CREATE INDEX statement.

You might also like