SQL Syntax

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

SELECT extracts data from a database

UPDATE updates data in a database


DELETE deletes data from a database
INSERT INTO inserts new data into a database
CREATE DATABASE creates a new database
ALTER DATABASE modifies a database
CREATE TABLE creates a new table
ALTER TABLE modifies a table
DROP TABLE deletes a table
CREATE INDEX creates an index (search key)
DROP INDEX deletes an index

Basic SQL Syntax:

 Data Definition Language (DDL):


o CREATE DATABASE: Creates a new database.
o CREATE TABLE: Creates a new table within a database, specifying columns and
data types.
o ALTER TABLE: Modifies the structure of an existing table (adding, deleting, or
modifying columns).
o DROP TABLE: Deletes a table from the database.
 Data Manipulation Language (DML):
o INSERT INTO: Inserts new rows of data into a table.
o SELECT: Retrieves data from one or more tables based on specific criteria.
o UPDATE: Modifies existing data in a table.
o DELETE FROM: Deletes rows of data from a table based on specific criteria.
 Data Control Language (DCL):
o GRANT: Gives permissions to users to perform specific actions on database
objects.
o REVOKE: Takes away permissions granted to users.

Intermediate SQL Syntax:

 JOINs: Combine data from multiple tables based on a relationship between columns
(e.g., INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN).
 WHERE Clause: Filters data based on a specific condition.
 GROUP BY: Groups data together based on a column and performs aggregate functions
(e.g., SUM, COUNT, AVG).
 HAVING Clause: Filters groups created by the GROUP BY clause based on a condition
applied to aggregate functions.
 ORDER BY: Sorts the results of a query in ascending or descending order based on a
specific column.
 Subqueries: Nested queries that can be used to retrieve data based on the results of
another query.
Advanced SQL Syntax:

 Window Functions: Perform calculations on a set of rows within a partition or ordered


result set (e.g., RANK, ROW_NUMBER, PERCENTILE).
 Common Table Expressions (CTEs): Temporary named result sets that can be used
within a larger query for improved readability and modularity.
 Cursors: Iterative statements that allow you to process data row by row.
 Triggers: Database procedures that are automatically executed based on specific events
(e.g., INSERT, UPDATE, DELETE).
 Stored Procedures and Functions: Reusable blocks of SQL code that can be pre-
defined and called upon within queries for code optimization and modularity.
 Views: Virtual tables based on a SELECT query, providing a simplified or filtered view
of the underlying data.

Additional Notes:

 This is not an exhaustive list, and there are many other SQL functionalities and features
available depending on the specific database management system you're using.
 As you progress in your SQL learning journey, you'll delve deeper into advanced
concepts and explore functionalities specific to your chosen database platform.

Remember, practice is key! Try implementing these SQL commands to solidify your
understanding. There are many online resources and tutorials available to help you practice and
explore more advanced SQL concepts.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy