Fundamentals of databases: Structured Query Language (SQL)
Specification
[edit | edit source]
Specification coverage
|
Introduction
[edit | edit source]
Structured Query Language (SQL) is a specialised programming language that is used for managing relational databases. Its functions allow users to define tables, insert, update and delete data and to carry out queries on data to produce and output subsets of the main data. In common with other programming languages, SQL works by typing lines of code.
Reserved words When you are writing SQL you might get some unexpected errors, where a query fails to run when it doesn't appear to have any problem with it. This may be due to using a reserved word in your query. SQL has a lot of reserved words, words that have special meanings, and if you use one of these in a query it won't treat it as a field name. For example: SELECT Username, Password FROM tblUsers
This might bring up an error as SELECT Username, [Password] FROM tblUsers
There are many other reserved words out there, so be careful: PERCENT, PLAN, PRECISION, EXISTS, PRIMARY, PRINT, PUBLIC,
BACKUP, FOREIGN, READ,FREETEXT, FROM, REFERENCES, BULK,
FULL, RESTORE, GROUP, IDENTITY, RULE, SAVE, INDEX, SELECT,
STATISTICS, KEY, TABLE, NATIONAL, DATABASE, UNION, DELETE,
DISK, ON, USER, PASSWORD
Different databases have different sets of reserved words, you can find a good list here Note: If you are not using a SQL server (for example, using MySQL with PHP) you may need to use `backticks` instead of square bracket notation. |