Differences between version 6 and predecessor to the previous major change of SQL.
Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 6 | Last edited on Monday, May 15, 2006 4:16:21 pm | by CraigBox | Revert |
Older page: | version 5 | Last edited on Wednesday, November 19, 2003 4:58:49 pm | by AristotlePagaltzis | Revert |
@@ -1,13 +1,26 @@
-[Acronym] for either
__S__tructured or __S__imple
__Q__uery __L__anguage - noone is quite certain
. Also resolved as __
S__tupid __Q__uery __L__anguage
.
+[Acronym] for __S__tructured __Q__uery __L__anguage. Some database professionals think the
S should stand for 'stupid'
.
-It's
a set-centric ProgrammingLanguage in which statements are excuted over a [Schema] of relations (tables) and return a set of results.
+SQL is
a set-centric ProgrammingLanguage in which statements are excuted over a [Schema] of relations (tables),
and return a set of results.
-AddToMe: Someone should explain the general syntax of [SQL] here.
+!!Syntax & examples
-
SELECT ''cols'' FROM ''tables'' WHERE ''condition''
- UPDATE ''table'' SET ''column''=''value'' WHERE ''condition''
- DELETE FROM ''table'' WHERE ''condition''
- INSERT INTO ''table'' (''columns'') VALUES (''values'')
+In this example, imagine we have a table called 'users' which has links an 'id', a 'name' and an 'accesslevel'.
+
+__Retrieving data:__
+
+ <tt>
SELECT ''cols'' FROM ''tables'' WHERE ''condition''</tt>%%%eg to find the access level of user number 154: <tt>SELECT accesslevel FROM users WHERE id = 154;</tt>
+
+__Inserting data:__
+
+ <tt>INSERT INTO ''table'' (''columns'') VALUES (''values'')</tt>%%%eg to add a new user: <tt>INSERT INTO users (name, accesslevel) VALUES ('Craig', 10);</tt> - the next available ID number is automatically assigned.
+
+__Updating data:__
+
+ <tt>
UPDATE ''table'' SET ''column''=''value'' WHERE ''condition''</tt>%%%eg to set an accesslevel of 15 to everyone whos name starts with a C: <tt>UPDATE users SET accesslevel=15 WHERE name LIKE 'C%';</tt>
+
+__Removing data:__
+
+ <tt>
DELETE FROM ''table'' WHERE ''condition''</tt>%%%eg Remove user with ID number 30: <tt>DELETE FROM users WHERE id = 30;</tt>
----
CategoryProgrammingLanguages, CategorySpecialPurposeProgrammingLanguages