SQL (structured Query Language) is a computer language used to retrieve and manage data in relational DBMS. It can also be used to create and manage the different schema used in the database. SQL was first standardized by ANSI, and is now an ISO standard, Most DBMS use the standardized SQL, but also expand upon it and add some proprietary aspects to it. SQL is a declarative language, meaning that the end user will only explain the logic of the operation, and will not explain the algorithms with which the computer will complete the operation, however as stated above some vendors expand upon standardized SQL, and some included procedural elements to SQL, since this aspect is proprietary to the DBMS, we will not go into detail. Most operations that users will do in SQL are queries, which are used to retrieve data.
The following shows a typical SQL statement, and it is structured.
The capitalized words are keywords, reserved by SQL (meaning that users cannot use theses words for anything else than the actual SQL opeartion), the other words are names of fields (columns). As we can see, an SQL statement starts with the operation to do, followed by the field on which to do the operation, and then, the conditions. A single operation can affect multiple fields, in multiple tables. Wild card operator are also permited in sql, such as * for anything, or ? for any one character.
A few examples:
-Retrieve all the fields of the users with the name John.
SELECT * FROM users WHERE user_name = 'John'
- Retrieve all the unique entries in the names of the users
SELECT DISTINCT user_name FROM users
-Multiple conditions are also allowed, such as all the users named John or Jack
SELECT * FROM users WHERE user_name = 'John' OR user_name = 'Jack'
sources/further reading
http://www.w3schools.com/sql/default.asp
http://en.wikipedia.org/wiki/Sql
Monday, April 6, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment