Differences between version 7 and predecessor to the previous major change of SQL.
Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 7 | Last edited on Monday, May 15, 2006 4:57:03 pm | by AristotlePagaltzis | Revert |
Older page: | version 5 | Last edited on Wednesday, November 19, 2003 4:58:49 pm | by AristotlePagaltzis | Revert |
@@ -1,13 +1,60 @@
-[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 table
of results.
-AddToMe: Someone should explain the general syntax of [SQL] here.
+!! Syntax and 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 <tt>users</tt> which has an <tt>id</tt>, a <tt>name</tt> and an <tt>accesslevel</tt> column.
+
+__Retrieving data:__
+
+ <pre>
+
SELECT ''cols'' FROM ''tables'' WHERE ''condition''
+ </pre>
+
+ Eg. to find the access level of user number 154:''''
+
+ <pre>
+ SELECT accesslevel FROM users WHERE id = 154;
+ </pre>
+
+__Inserting data:__
+
+ <pre>
+ INSERT INTO ''table'' (''columns'') VALUES (''values'')
+ </pre>
+
+ Eg. to add a new user:''''
+
+ <pre>
+ INSERT INTO users (name, accesslevel) VALUES ('Craig', 10);
+ </pre>
+
+ The next available ID number is automatically assigned.
+
+__Updating data:__
+
+ <pre>
+
UPDATE ''table'' SET ''column''=''value'' WHERE ''condition''
+ </pre>
+
+ Eg. to set an accesslevel of 15 to everyone whos name starts with a C:
''''
+
+ <pre>
+ UPDATE users SET accesslevel=15
WHERE name LIKE
'C%
';
+ </pre>
+
+__Removing data:__
+
+ <pre>
+ DELETE FROM
''table'' WHERE
''condition
''
+ </pre>
+
+ Eg. to remove the user with ID number 30:
''''
+
+ <pre>
+ DELETE FROM users WHERE id = 30;
+ </pre>
----
-CategoryProgrammingLanguages,
CategorySpecialPurposeProgrammingLanguages
+Part of
CategoryProgrammingLanguages and
CategorySpecialPurposeProgrammingLanguages