|
|
SQLStructured Query Language (SQL) is the most popular computer language used to create, modify and retrieve data from relational database management systems. The language has evolved beyond its original purpose to support object-relational database management systems. It is an American National Standards Institute/International Organization for Standardization standard. ==History== A seminal paper, [http://www.acm.org/classics/nov95/toc.html "A Relational Model of Data for Large Shared Data Banks"], by Dr. Edgar F. Codd, was published in June, 1970 in the Association for Computing Machinery (ACM) journal, Communications of the ACM. Codd's model became widely accepted as the definitive model for ''relational'' database management systems (RDBMS). During the 1970s, a group at IBM San Jose research center developed a database system "System R" based upon Codd's model. Structured English Query Language (''"SEQUEL"'') was designed to manipulate and retrieve data stored in System R. The acronym ''SEQUEL'' was later condensed to SQL due to a trademark dispute (the word 'SEQUEL' was held as a trade mark by the Hawker-Siddeley aircraft company of the UK). In 1978, methodical testing commenced at customer test sites. Demonstrating both the usefulness and practicality of the system, this testing proved to be a success for IBM. As a result, IBM began to develop commercial products that implemented SQL based on their System R prototype, including SQL/DS (introduced in 1981), and DB2 (in 1983). In 1979, Relational Software, Inc. (now Oracle Corporation) introduced the first commercially available implementation of SQL (Oracle actually beat IBM to market by two years by releasing their first commercial RDBMS) and soon, many other vendors developed dialects of it. SQL was adopted as a standard by the ANSI (American National Standards Institute) in 1986 and ISO (International Organization for Standardization) in 1987. ANSI has declared that the official pronunciation for SQL is ''"ess kyoo ell"'', although many English-speaking database professionals still pronounce it as ''sequel''. The SQL standard has gone through a number of revisions: {| border=1 ! Year !! Name !! Alias !! Comments |- valign=top | 1986 || SQL-86 || SQL-87 || First published by ANSI. Ratified by ISO in 1987. |- valign=top | 1989 || SQL-89 || || Minor revision. |- valign=top | 1992 || SQL-92 || SQL2 || Major revision. |- valign=top | 1999 || SQL:1999 || SQL3 || Added regular expression matching, recursive queries, triggers, non-scalar types and some object-oriented features. (The last two are somewhat controversial and not yet widely supported.) |- valign=top | 2003 || SQL:2003 || || Introduced XML-related features, ''window functions'', standardized sequences and columns with auto-generated values (including identity-columns). (See [http://www.acm.org/sigmod/record/issues/0403/index.html#standards Eisenberg et al.: ''SQL:2003 Has Been Published''].) |} The SQL standard is not freely available. SQL:2003 may be purchased from [http://www.iso.org/ ISO] or [http://webstore.ansi.org/ ANSI]. A late draft is available as a [http://www.wiscorp.com/sql/sql_2003_standard.zip zip archive] from [http://www.wiscorp.com/ Whitemarsh Information Systems Corporation]. The zip archive contains a number of Portable Document Format files that define the parts of the SQL:2003 specification. Although SQL is defined by both ANSI and ISO, there are many extensions to and variations on the version of the language defined by these standards bodies. Many of these extensions 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 programming language 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. There are several reasons for this lack of portability between database systems:
*the complexity and size of the SQL standard means that most databases do not implement the entire standard.
*the standard does not specify database behavior in several important areas (e.g. indexes), leaving it up to implementations of the standard to decide how to behave.
*the SQL standard precisely specifies the syntax that a conformant database system must implement. However, the standard's specification of the semantics of language constructs is less well-defined, leading to areas of ambiguity.
*many database vendors have large existing customer bases; where the SQL standard conflicts with the prior behavior of the vendor's database, the vendor may be unwilling to break backward compatibility.
*some believe the lack of compatibility between database systems is intentional in order to ensure vendor lock-in.
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, Declarative programming language computer language rather than an Imperative programming such as C or BASIC programming language which, being programming languages, are designed to solve a much broader set of problems. Language extensions such as PL SQL are designed to address this by turning SQL into a full-fledged programming language while maintaining the advantages of SQL. Another approach is to allow programming language code to be embedded in and interact with the database. For example, Oracle and others include Java programming language in the database, while PostgreSQL allows functions to be written in a wide variety of languages, including Perl, Tcl, and C.
One joke about SQL is that "SQL is neither structured, nor is it limited to queries, nor is it a language." This is founded on the notion that ''pure'' SQL is not a classic programming language since it is not ''Turing complete''. On the other hand, however, it is a programming language because it has a grammar, syntax, and programmatic purpose and intent. The joke recalls Voltaire's remark that the Holy Roman Empire was "neither holy, nor Roman, nor an empire."
==Description of SQL==
SQL allows the specification of queries in a high-level, declarative manner. For example, to select rows from a database, the user need only specify the criteria that they want to search by; the details of performing the search operation efficiently is left up to the database system, and is invisible to the user.
Compared to general-purpose programming languages, this structure allows the user/programmer to be less familiar with the technical details of the data and how they are stored, and relatively more familiar with the information contained in the data. This blurs the line between user and programmer, appealing to individuals who fall more into the 'business' or 'research' area and less in the 'information technology' area. The original vision for SQL was to allow non-technical users to write their own database queries. While this has been realized to some extent, the complexity of querying an advanced database system using SQL can still require a significant learning curve.
SQL contrasts with the more powerful Fourth-generation programming language such as Focus software or SAS Institute, however, in its relative functional simplicity and simpler command set. This greatly reduces the degree of difficulty involved in maintaining the worst SQL source code, but it also makes programming such questions as 'Who had the top ten scores?' more difficult, leading to the development of procedural extensions, discussed #Origins. However, it also makes it possible for SQL source code to be produced (and optimized) by software, leading to the development of a number of natural language database query languages, as well as 'drag and drop' database programming packages with 'object oriented' interfaces. Often these allow the resultant SQL source code to be examined, for educational purposes, further enhancement, or to be used in a different environment.
==SQL keywords==
SQL keywords fall into several groups.
===Data retrieval===
The most frequently used operation in transactional databases is the data retrieval operation.
* Select (SQL) is used to retrieve zero or more rows from one or more tables in a database. In most applications, SELECT is the most commonly used DML command. In specifying a SELECT query, the user specifies a description of the desired result set, but they do ''not'' specify what physical operations must be executed to produce that result set. Translating the query into an optimal query plan is left to the database system, more specifically to the query optimizer.
** Commonly available keywords related to SELECT include:
*** FROM is used to indicate which tables the data is to be taken from, as well as how the tables Join (SQL) to each other.
*** WHERE is used to identify which rows to be retrieved, or applied to GROUP BY.
*** GROUP BY is used to combine rows with related values into elements of a smaller set of rows.
*** HAVING is used to identify which rows, following a GROUP BY, are to be retrieved.
*** ORDER BY is used to identify which columns are used to sort the resulting data.
===Data manipulation===
First there are the standard Data Manipulation Language (DML) elements. DML is the subset of the language used to add, update and delete data.
*Insert (SQL) is used to add zero or more rows (formally tuples) to an existing table.
*Update (SQL) is used to modify the values of a set of existing table rows.
*Merge (SQL) is used to combine the data of multiple tables. It is something of a combination of the INSERT and UPDATE elements.
*Delete (SQL) removes zero or more existing rows from a table.
*Truncate (SQL) deletes all data from a table (non-standard, but common SQL command).
===Data transaction===
Transaction, if available, can be used to wrap around the DML operations.
* Begin work (SQL) (or Start transaction (SQL), depending on SQL dialect) can be used to mark the start of a database transaction, which either completes completely or not at all.
* Commit (SQL) causes all data changes in a transaction to be made permanent.
* Rollback (SQL) 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.
===Data definition===
The second group of keywords is the Data Definition Language (DDL). 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 nonstandard features of the database system.
The most basic items of DDL are the CREATE and DROP commands.
* Create (SQL) causes an object (a table, for example) to be created within the database.
* Drop (SQL) causes an existing object within the database to be deleted, usually irretrievably.
Some database systems also have an Alter (SQL) command, which permits the user to modify an existing object in various ways -- for example, adding a column to an existing table.
===Data control===
The third group of SQL keywords is the Data Control Language (DCL). 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 (SQL) - authorises a user to perform an operation or a set of operations.
* Revoke (SQL) - removes or restricts the capability of a user to perform an operation or a set of operations.
==Database systems using SQL==
*List of relational database management systems
*List of object-relational database management systems
==Criticisms of SQL==
Technically, SQL is a declarative computer language for use with "relational databases". Theorists note that many of the original SQL features were inspired by, but in violation of, tuple calculus. Recent extensions to SQL achieved relational completeness, but have worsened the violations, as documented in The Third Manifesto.
In addition, there are also some criticisms about the practical use of SQL:
*The language syntax is rather complex (sometimes called "COBOL-like").
*It does not provide a standard way to split large commands into multiple smaller ones that reference each other by name (however some implementations allow for set-based functions to grant this functionality). This tends to result in "run-on SQL sentences"
*Implementations are inconsistent and, at times, incompatible between vendors.
*It is at times too difficult a syntax for Database administrators (database administrators) to extend.
*Over-reliance on "Nulls", which some consider a flawed or over-used concept.
==Alternatives to SQL==
*IBM BS12
*[http://www.dbdebunk.com/ Tutorial-D - A language by C. J. Date and colleagues]
*[http://www.c2.com/cgi/wiki?TqlRoadmap TQL Proposal (Not to be confused with Luca Cardelli's TQL)]
*[http://www.hibernate.org/hib_docs/v3/reference/en/html/queryhql.html Hibernate Query Language (HQL) - A Java-based tool that uses modified SQL]
==External links==
*[http://www.windowsecurity.com/articles/Secure_Architecture_SQL_Web_Server.html Secure Architecture for an SQL Server]
*[http://www.dbdebunk.com/ Database Debunking]
*[http://www.orafaq.com/faqsql.htm Oracle SQL FAQ]
*[http://www.mcjones.org/System_R/SQL_Reunion_95/ History of SQL]
*[http://troels.arvin.dk/db/rdbms/ Comparison of different SQL implementations]
*[http://www.sqlkingdom.com/ SQL related software archive]
*[http://www.mcjones.org/System_R/SQL_Reunion_95/sqlr95-System.html The 1995 SQL Reunion: People, Projects, and Politics - System R]
===Tutorials===
*[http://aam.ugpl.de/sql_help SQL Help and Tutorial]
*[http://www.bitesizeinc.net/sql.html BiteSize Inc.'s ''Learn SQL'' tutorial]
*[http://sqlcourse.com/ Jupitermedia Corporation's online SQL tutorial]
*[http://sqlzoo.net/ ''A Gentle Introduction to SQL'' at SQLzoo]
*[http://www.sql-tutorial.net SQL Tutorial]
*[http://www.intermedia.net/support/sql/sqltut.asp#Basics%20of%20the%20SELECT%20Statement ''Introduction to Structured Query Language'' by James Hoffman]
*[http://www.cfxweb.net/modules.php?name=News&file=article&sid=161 SQL for beginners]
SQL
Computer languages
SQL== a "programming language"? == Should we really call it a "programming language"? user:AxelBoldt ::That depends, IMHO, on whether the expressive power of SQL is equivalent to that of a Turing machine. I myself can't remember, but I seem to remember reading somewhere that it is (or at least, that the relational calculus is equally expressive). If SQL is has the same expressive power as a Turing machine, then technically it could be called a programming language (though "Structured Query Language Programming Language" seems, to me, not only to be redundant, but also inconsistent). UPDATE: Oops, I think I was wrong (at least about standard SQL); see http://cgibin.erols.com/ziring/cgi-bin/cep/cep.pl?_get=epl_desc.phtml and search for string "standard SQL". :::Show me an SQL statement which, starting from an empty database, takes a natural number ''n'' as input and produces the ''n''-th prime number as output, and I'll eat my MySQL server. user:AxelBoldt ::::Nice challenge, Axel -- lemme think about this for a while -- User:ClaudeMuncey ::::*Nice? You have a better chance of winning the lotto twice in a row. — User:Danakil 17:00, Sep 5, 2004 (UTC) ::::*Are you done yet? :-) SQL is certainly not computationally complete, even if you take into account that it can do a little arithmetic and even if you add some kind of recursion. That's why for programming it is usually extended with programming language construct such as in PL/SQL which I ''would'' call a programming language. So I suggest we move it to SQL query language or just SQL if there is no other SQL in Wikipedia. -- User:Jan Hidders 14:33 Jan 22, 2003 (UTC) ::::::I agree with the suggestion to move ''SQL programming language'' to just ''SQL''. --User:Hirzel Jan 22, 2003 ::The page currently states that "As such, it is a set-based programming language". And nothing on http://en.wikipedia.org/wiki/Programming_Language prevents SQL to be called a programming language (the page even lists SQL among the "Major programming languages"), although a very declarative and domain specific one. Now, http://en.wikipedia.org/wiki/User:Danakil claims that SQL cannot be called a programming language, see http://en.wikipedia.org/w/wiki.phtml?title=SQL&diff=0&oldid=5653966 I suggest that we accept SQL as a programming language until someone writes up a proper wiki page about query languages. User:Tarvin ::*Programming language does not currently exclude non-programming languages because that article is in the process of a major rewrite and this has had rather unfortunate effects on the malleability of the current text. It should be fixed soon. SQL is a: :::#set-based (vs. array-based or logic-rule-based, for example) :::#declarative (vs. imperative, that is, it does not rely on a state and a series of steps to change that state bit by bit) :::#query language (vs. programming language, that is, there are many things it cannot do... such as making User:AxelBoldt eat his MySQL server—see above) :::All three of the former characteristics are ''orthogonal'', i.e., you could have one without the others. — User:Danakil 16:48, Sep 5, 2004 (UTC) ---- :::You also have to make a careful distinction between the relational calculus as a general method in set theory and the various versions of SQL (no matter how much we love/hate/tolerate it). Chris Date has nearly made a career in recent years pointing out the deficiencies in SQL as an implementation of either relational calculus or algebra. User:ClaudeMuncey ------- http://www.c2.com/cgi/wiki?SqlFlaws - Discussion of possible SQL flaws ---- The spelled-out name is 1000x less common than the initials (according to google), and the initials don't have any other common meanings. I think the full name should redir to the initials. Any reason not to? User:Stan Shebs 19:52, 23 Oct 2003 (UTC) : I'm surprised it wasn't moved there already. You certainly have my vote. User:Jan Hidders 15:41, 24 Oct 2003 (UTC) ::Done. Hopefully the next person to get the urge to move it back to the spelled-out name will see this bit of the talk page and reconsider. :-) User:Stan Shebs 17:15, 24 Oct 2003 (UTC) == vendor lock-in? == From the article: :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. Is this really true? Are there any references to back up the "most people in the field..." assertion? I think there are some equally plausible reasons for the lack of compatibility between implementations of SQL: * SQL is very large (the spec is 1500+ pages) and complex; it's also ambiguous in places and difficult to understand. Even understanding what ''is'' standards-conformant behavior can be tricky in some situations. * Database vendors tend to be conservative about making backward-incompatible changes. Since many vendors already implemented some features (say, stored procedures or sequences) in one way or another before they appeared in the standard, it can be difficult to migrate from the vendor's implementation of the concept to the standards-compliant implementation. * Databases are extremely complexes pieces of software, and the ability of any standards document to allow for easy portability between different database systems is limited (the large swaths of functionality that are treated as implementation-defined by the SQL standard is one major example of this). So blaming the poor state of compatibility solely on vendors (and worse yet, claiming that it is an intentional decision on their part) doesn't seem to be telling the whole story. -- User:Neilc 06:40, 30 Jul 2004 (UTC) == Acronym or not? == Different sources give different definition of the "SQL" name: * Some claim that it stands for Structured Query Language, and that's also what the page currently indicates in the first paragraph. * Some claim it's recursive acronym, short for SQL Query Language. * Some claim it's not an acrynym at all (that the three letters aren't short for anything else). I can't find a definite source (did a superficial search in part 1 of SQL:2003). Can somone else? User:Tarvin The difinitive authority on SQL is NIST. Look up the acronym of SQL at [http://physics.nist.gov/GenInt/acronyms.html#S] and you will see that it stands for Structured Query Language. Since this fact seems obscure to at least one person, perhaps we need a history lesson on where SQL came from, and who now has administrive authority over defining what is, and what is not, SQL. User:KeyStroke :According to [http://books.elsevier.com/mk/default.asp?isbn=1558604561 Melton/Simon: SQL:1999]: :*NIST is not involved in the SQL standard any more (page 842), so they cannot be regarded "definitive authority" of SQL. :*About the transition from SEQUEL/2 to SQL: "''No doubt, this is the source of the popular belief that SQL stands for Structured Query Language''" (page 24) :One of the authors (Melton) of the cited book was editor of the SQL-92 and SQL:1999 standard-revisions, as well as the U.S. representative in the related ISO/IEC committee. :In short, I believe that Wikipedia currently contains a factual error about the "meaning" of SQL. I assert that SQL officially has no mening, although a strong urban legend equates it with an acronym for "Structured Query Language". :- Oh, and in ''http://www.awprofessional.com/title/0201964260 '', it's explicitly stated that SQL officially isn't an acronym for anything. :User:Tarvin 14:33, 6 Dec 2004 (UTC) == "Problem" of INSERT and UPDATE == The article currently states that the following is a problem in SQL: :"The syntax of INSERT and UPDATE differ, which can be difficult to work with." I don't see why that's a problem, and it's not criticism that I've seen in commonly expressed in literature. At any rate, I wouldn't consider it big enough to be mentioned in an encyclopedic article (could fit well into someone's weblog, though). Am I overlooking something important? User:Tarvin 14:05, 6 Dec 2004 (UTC) :Personally, I just think it was someone's rant. I edited it, because I suppose I cna see it being annoying... but, no, I do not believe it's really a valid criticism. :I would suggest changing the "possible criticisms of SQL" to simply, "Criticisms of SQL". That removes the feeling that even minor criticisms could be put there as well. Following that, I think I might rewrite it as follows: * The various implementations of SQL listed above tend to differ in syntax and optimization, making it difficult to write queries that run anywhere. * The overall syntax is, in cases, more complex than it needs to be. * Code cannot exactly be compiled, depending on the implementation, meaning that a program using SQL will have SQL strings throughout it. * Nulls are used extensively throughout SQL, but are considered by many to be a flawed or overused concept. :I'm not sure if this is really better, but I've added one you may not agree with - I'm not sure how best to word it, but the basic point is that if I wanted to write a C programming language program that used MySQL, the best way for me to do this would be to have the queries as strings (uncompiled.) This is somsething I know has been criticized before. However, the point about "run-on SQL sentences" makes no sense to me, because you have VIEWs, FUNCTIONs, sub queries, and various other methodogolies to conflict this. :Further, I changed the order to what I (again, personally, and this is why I'm not changing the page this second to what I typed above) feel is most important to least important. The first one is by far the worst - even inside implementations... for example, SQL may be well optimized for MySQL 3.23.x, but that doesn't mean it's properly optimized for MySQL 4.0.x. -[[User:Unknown W. Brackets|[Unknown]]] 19:23, Dec 6, 2004 (UTC) ::Comments: ::*I think your suggested rewrite is an improvement. ::*About your strings-in-compiled-code criticism: I think it's too product-specific to mention in a general page about SQL (embedded SQL is a rather old concept which many DBMSes offer). ::*About the current "''It does not provide a standard way to split large commands into multiple smaller ones ...''" statement: Yes, let's get rid of it; it's simply not true, ''especially'' since SQL:1999 (and DB2) which introduced the WITH ... AS construct for 'temporary' (sort-of) views. ::Something which I think is missing among the criticism points: The stanards-development is very closed. I.e., I've never seen anyone from the SC32 WorkGroup on any public discussion forum/newsgroup (I've often had the desire to ask someone authoritative how something specific in the standard is to be interpreted, but there is nowhere to go for answers). I've never seen them ask for public comments, or comment on the discussions they have. I believe that this is rather different from - e.g. - the C++ standardization process. But that might just be me. ::User:Tarvin 19:43, 6 Dec 2004 (UTC) == Template:Cleanup-technical == Template:Cleanup-technical or SQL#REDIRECT Wikipedia:SQL_queries SQLStructured Query Language (SQL) is one of the most popular computer languages used to create, modify and query databases. Database management systems Query languages Sql#redirect SQL See other meanings of words starting from letter: SSB | SC | SD | SE | SF | SG | SH | SI | SJ | SK | SL | SM | SN | SO | SP | SR | SS | ST | SU | SW | SX | SY | SZ |Words begining with SQL: SQL SQL SQL SQL Sql Sql3 Sqlislogged SQLite SQLite Sqlite SQLite_Database_Browser Sqlquery SQLSlammer SQL_Anywhere_Studio SQL_Injection SQL_injection Sql_injection SQL_keywords SQL_language SQL_Ledger SQL_programming_language SQL_programming_language SQL_queries SQL_query_requests SQL_query_requests SQL_requests SQL_Server SQL_Server SQL_server Sql_server SQL_Server_2000 Sql_Server_2000 SQL_Slammer SQL_slammer_worm SQL_slammer_worm |
These materials are based on Wikipedia and licensed under the GNU FDL
YouTube.com videos better site than Turbo Tax 2007 |
|
|