community
directory
books
authors
images
encyclopedia

Email:
Password:
Register

Knowledgerush Search

 

Google
  Web knowledgerush


Search for images of SQL


Message boards   Post comment

SQL

Structured Query Language, or SQL, is a declarative programming language for use in quasi-relational databases. Many of the original SQL features were inspired by, but in violation of, tuple calculus, but recent extensions to SQL include a more relational algebra flavour.

SQL was originally created by IBM, but many vendors developed dialects of it. It was adopted as a standard by the American National Standards Institute(ANSI) in 1986 and ISO in 1987. In their SQL standard, the ANSI declared that the official pronunciation for SQL is "es queue el". However, many database professionals have taken to the "slang" pronunciation sequel, that reflects the language's original name, Sequel, before trademark conflicts caused IBM to perpetrate the current moniker.

SQL was revised in 1992, and that version is known as SQL-92. It was again revised in 1999 to become SQL:1999 (AKA SQL3). SQL:1999 supports objects, which weren't previously supported in other versions, but as of late 2001, few database management systems implement SQL:1999.

SQL, although defined by both ANSI and ISO, has many variations and extensions, most of which are of a proprietary nature, such as Oracle Corporation's PL/SQL or Sybase and Microsoft's Transact-SQL. It is also not uncommon for commercial implementations to omit support for basic features of the standard, such as the DATE or TIME data types, preferring some variant of their own. As a result in contrast to ANSI C or ANSI Fortran which can usually be ported from platform to platform without major structural changes, SQL code can rarely be ported between database systems without major modifications. Most people in the field believe that this lack of compatibility is intentional in order to ensure vendor lock-in for proprietary database systems.

As the name implies, SQL is designed for a specific, limited purpose -- querying data contained in a relational database. As such, it is a set-based programming language rather than a procedural language such as C or BASIC, which are designed to solve a much broader set of problems. Language extensions such as PL/SQL are designed to address this by adding procedural elements to SQL while maintaining SQL's advantages. Another approach is to allow procedural language code to be embedded in and interact with the database. For example, Oracle and others include Java in the database, while PostgreSQL allows functions to be written in Perl, Tcl, or C, among other languages. Microsoft uses SQL Visual Basic.

One joke about SQL is that "SQL is neither Structured, nor a Language." This is (in part) founded on the notion that SQL isn't a Turing complete language.

Examples

Table 'T' Query Result
C1 C2
1 a
2 b
Select * from T
C1 C2
1 a
2 b
C1 C2
1 a
2 b
Select C1 from T
C1
1
2
C1 C2
1 a
2 b
Select * from T where C1=1
C1 C2
1 a

Given a table T, the query Select * from T will result in all the elements of all the rows of the table being shown.

With the same table, the query Select C1 from T will result in the elements from the column C1 of all the rows of the table being shown.

With the same table, the query Select * from T where C1=1 will result in all the elements of all the rows where the value of column C1 is '1' being shown.

SQL keywords

SQL keywords fall into a number of groups.

First there are the standard Data Manipulation Language elements. DML is the subset of the language used to query a database, add, update and delete data.

  • SELECT is the most commonly used DML command and allows the user to specify a query as a description of the desired result set. The query does not specify how the results should be located - turning a query into a form which can be executed is the job of the database system, more specifically of the Query Optimiser.

  • INSERT is used to add a row (formally a tuple) to an existing table.

  • UPDATE is used to change the data values in an existing table row.

  • DELETE permits existing rows to be removed from a table.

Three other keywords could be said to fall into DML:

  • BEGIN WORK (or START TRANSACTION, depending on SQL dialect) can be used to mark the start of a database transaction, which either completes completely or not at all.

  • COMMIT causes all data changes in a transaction to be made permanent.

  • ROLLBACK causes all data changes since the last COMMIT or ROLLBACK to be discarded, so that the state of the data is "rolled back" to the way it was prior to those changes being requested.

COMMIT and ROLLBACK interact with areas such as transaction control and locking. Strictly, both terminate any open transaction and release any locks held on data. In the absence of a BEGIN WORK or similar statement, the semantics of SQL are implementation-dependent.

The second group of keywords is the Data Definition Language. DDL allows the user to define new tables and associated elements. Most commercial SQL databases have proprietary extensions in their DDL, which allow control over proprietary and nonstandard, but usually operationally vital, elements of the specific system.

The most basic items of DDL are the CREATE and DROP commands.

  • CREATE causes an object (a table, for example) to be created within the database.

  • DROP causes an existing object within the database to be deleted, usually irretrievably.

Some database systems also have an ALTER command, which permits the user to modify an existing object in various ways - for example, adding a column to an existing table.

The third group of SQL keywords is the Data Control Language. DCL handles the authorisation aspects of data and permits the user to control who has access to see or manipulate data within the database.

Its two main keywords are

  • GRANT - authorises a user to perform an operation or a set of operations.

  • REVOKE - removes or restricts the capability of a user to perform an operation or a set of operations.

Database systems using SQL

External links

Referenced By

AS/400 | AS400 | Access | Anglo | BS12 | Business System 12 | Call Level Interface | Categorical list of programming languages | Clarion | Clean programming language | Commujism | Comparison of Java to Cplusplus | Concurrent Clean | DBMS | Data Definition Language | Database | Database applications | Database management system | Database software | Database system | Database transaction | Declarative programming | Declarative programming language | Electronic Data Interchange | English | English (disambiguation) | English programming language | Enterprise Objects Foundation | Enterprise Objects Framework | Firebird (database server) | GPE Palmtop Environment | Harvey Mudd College | Hello, world! | Hello World | Hello world program | IBM BS12 | IBM DB2 | ISeries | Impedance mismatch | Informix | Internet forum | JDBC | Java Database Connectivity | KDevelop | List of ISO standards | List of TLAs | Maddox | Maddox.xmission.com | Maddox.xmission.net | Maddox.xmission.org | Microsoft Access | Microsoft SQL Server | Mimer SQL | MyPHPNuke | MySQL | ODBC | Object-relational database | Object-relational mapping | Online forum | Open Database Connectivity | Open standard | Open standards | PHP-Nuke | PL/SQL | PL SQL | Perl | Perl programming language | Phpnuke | Pick Operating System | Platform Specific Model | PostgreSQL | Postgres | Practical Extraction and Report Language | QT Toolkit | QUEL | Relational DBMS | Relational model | Reserved word | SQL Ledger | SQL Server | SQL Slammer | SQL slammer worm | SQLite | Softvelocity | Stored procedure | System R | TLAs from QAA to TZZ | Tandem Computers | The Best Page In The Universe | The hello world program | Thebestpageintheuniverse.com | Three-letter abbreviation | Three-letter acronym | Three Letter Abbreviation | Three Letter Acronym | Transact-SQL | Transaction | Tuple calculus | W32.SQLExp.Worm | Wildcard character ...

 

Compose Your Message

Your Email Address or Pen Name (optional):
Subject:
Your Message:
 

 

 

 

 

 

This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "SQL".

 

Contact UsPrivacy Statement & Terms of Use

 
Copyright © 1999-2003 Knowledgerush.com. All rights reserved.