SQL: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 34: Line 34:


SQL data statements are used to manipulate the data structures perviously defined using the [[#SQL_Schema_Statements_(DDL)|SQL schema statements]]. This SQL subset is also known as Data Manipulation Language (DML).
SQL data statements are used to manipulate the data structures perviously defined using the [[#SQL_Schema_Statements_(DDL)|SQL schema statements]]. This SQL subset is also known as Data Manipulation Language (DML).
<font color=darkkhaki>
Refactor [[PostgreSQL_DML_Operations#Internal|PostgreSQL DML Operations]] and surface in "Standard SQL" everything that can be handled with standard SQL.</font>
==<tt>INSERT</tt>==
==<tt>INSERT</tt>==
{{Internal|SQL_INSERT#Overview|<tt>INSERT</tt>}}
{{Internal|SQL_INSERT#Overview|<tt>INSERT</tt>}}

Revision as of 22:41, 22 May 2024

External

Internal

Overview

This article documents standard SQL. For database-specific extensions, we'll link to the databases-specific DML operations page.

SQL is a standard non-procedural language designed to work with relational databases, allowing the users to interact with the database instance by issuing schema statements, data statements and transaction statements.

SQL statements define the necessary inputs and outputs for the database interaction, but it does not define how the statements should be executed. The details of the execution are left to the database engine component known as the optimizer.

The first standard for the SQL language was published by the American National Standards Institute (ANSI) in 1986. Subsequent refinements led to new releases of the SQL standard in 1989, 1992, 1999, 2003, 2006, 2008, 2011, and 2016.

Relational Database Terminology

In a relational model, data is stored in a set of tables, also known as relations. Within a relation, data is organized in rows (records) and columns. Each row describes an entity. Each is uniquely identified by a primary key. The rows may contain columns that are copies of other tables' primary keys. These are knowns as foreign keys and are used in joining related data together.

Also see:

Relational Databases

Result Set

The result of an SQL query, known as a result set, is also a table maintained in memory.

View

SQL Schema Statements (DDL)

SQL schema statements are used to define the data structures stored in the database. This SQL subset is also known as Data Definition Language (DDL).

CREATE | ALTER | DROP TABLE

CREATE | ALTER | DROP TABLE

SQL Data Statements (DML)

SQL data statements are used to manipulate the data structures perviously defined using the SQL schema statements. This SQL subset is also known as Data Manipulation Language (DML).

INSERT

INSERT

UPDATE

UPDATE

DELETE

DELETE

Queries with SELECT

Queries with SELECT

SQL Transaction Statements

The SQL transaction statements are used to begin, end, and rollback transactions.

Transaction Statements

Standard SQL Data Types

Standard SQL Data Types

SQL NULL

NULL in conditions.

Indexes

Constraints

Set Operations

SQL Conditional Logic