You are on page 1of 6

2012

SQL Programming Language
SQL commands
A definition for the SQL programming language used in creating database systems and their importance with examples for the most famous commands used.

Amen Mukhlis Southern New Hampshire University 7/6/2012

SQL

Structured Query Language is a programming language designed for managing data in relational database management systems (RDBMS).Originally based upon relational algebra and tuple relational calculus, its scope includes data insert, query, update and delete, schema creation and modification, and data access control. (wikipedia.org, 2012)

What Can SQL do? (W3schools, 2012)
         

SQL can execute queries against a database SQL can retrieve data from a database SQL can insert records in a database SQL can update records in a database SQL can delete records from a database SQL can create new databases SQL can create new tables in a database SQL can create stored procedures in a database SQL can create views in a database SQL can set permissions on tables, procedures, and views

SELECT The select command is used to select data from the table or the data base and they are then to appear in the result table The command select is
SELECT * FROM table_name

Where you can replace the (*) with the required column(s)\row(s). An example for using the command is Consider the following table which is named in the Data based as Staff and illustrates the staff on File for SNHU With the course they are teaching and their respective departments

Last Name 1 2 3 Mukhlis Siddiqi Semenova

First Name Amen Arif Lana

Course QSO 510 IT 500 FIN 500

Department Project Management Information Technology Finance

We need to select the last names and first names from the table The command looks like
SELECT Last Name, First Name FROM staff

INSERT INTO

The INSERT INTO command allows the user to insert a new row in a table of data the user can specify the location of the row or insert it without specifying The command is:
INSERT INTO table_name (column1) VALUES (value1)

* The shaded command specify the row while the omitting this command will insert the row with out specifying the location on the table. An example for the insert command is You have the following data in table "staff" Last Name 1 2 3 Mukhlis Siddiqi Semenova First Name Amen Arif Lana Course QSO 510 IT 500 FIN 500 Department Project Management Information Technology Finance

To insert a new raw into the command is as follows: INSERT INTO STAFF VALUE (4, 'Robin ', ' Marc ', 'MBA210 ', 'MBA')

The table will be
Last Name 1 2 3 Mukhlis Siddiqi Semenova First Name Amen Arif Lana Course QSO 510 IT 500 FIN 500 Department Project Management Information Technology Finance

4

Robin

Marc

MBA210

MBA

UPDATE

The command UDATE is used to update existing data in the database tables The command is:
UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value

The example is
Last Name 1 2 3 4 Mukhlis Siddiqi Semenova Robin First Name Amen Arif Lana Marc Course QSO 510 IT 500 FIN 500 Department Project Management Information Technology Finance

We need to update the table to add the course and department for the Raw #5
UPDATE Staff SET Courses='MBA210', Department='MBA' WHERE LastName='Robin' AND FirstName='Marc'

The table will be updated to
Last Name 1 2 3 4 Mukhlis Siddiqi Semenova Robin First Name Amen Arif Lana Marc Course QSO 510 IT 500 FIN 500 MBA210 Department Project Management Information Technology Finance MBA

DELETE

The Delete command allows the user to delete certain data from the database tables The command is
DELETE FROM table_name WHERE some_column=some_value

The example for this command can be shown using the same table I used in the other examples We need to delete the Instructor Dr. Robin from the table (Assume he is not giving any summer courses) Then the command looks like
DELETE FROM staff WHERE LastName='Robin' AND FirstName='Marc'

Works Cited
sqlcommands.net. (2012). http://www.sqlcommands.net/. Retrieved 7 6, 2012, from http://www.sqlcommands.net/: http://www.sqlcommands.net/ W3schools. (2012). http://www.w3schools.com/sql/sql_intro.asp. Retrieved 7 6, 2012, from .w3schools.com: http://www.w3schools.com/sql/sql_intro.asp wikipedia.org. (2012). http://en.wikipedia.org/wiki/SQL. Retrieved 7 2012, from http://en.wikipedia.org/wiki/SQL