Differences between version 7 and revision by previous author of SQL.
Other diffs: Previous Major Revision, Previous Revision, 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 6 | Last edited on Monday, May 15, 2006 4:16:21 pm | by CraigBox | Revert |
@@ -1,26 +1,60 @@
-[Acronym] for __S__tructured __Q__uery __L__anguage. Some database
professionals think the S should stand for '
stupid'
.
+[Acronym] for __S__tructured __Q__uery __L__anguage. Some DataBase
professionals think the ''
S''
should stand for "
stupid."
-SQL is 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.
-!!Syntax &
examples
+!! Syntax and
examples
-In this example, imagine we have a table called '
users'
which has links
an '
id'
, a '
name'
and an '
accesslevel'
.
+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:__
- <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
>
+ <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:__
- <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.
+ <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:__
- <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
>
+ <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:__
- <tt
>DELETE FROM ''table'' WHERE ''condition''</tt
>%%%eg Remove
user with ID number 30: <tt
>DELETE FROM users WHERE id = 30;</tt
>
+ <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