Matt's SQL Reference |
index |
| Command | Description | Syntax | Example |
|---|---|---|---|
| Select | Retrieves data from the database | select columns from tables where conditions order by columns |
select last_name |
| select function(column) from tables group by column |
select department, count(last_name) | ||
| select columns from table aliase where conditions; | select c.last_name, d.suite |
||
| Insert | Adds a new row into a table, with the specified values for each column | insert into tablename values (value1, value2, value3); | insert into customers
|
| insert into tablename (column1, column2) values (value1, value2); | insert into customers
| ||
| insert into tablename select * from tablename2; | insert into customers
|
||
| Delete | Deletes a row or rows from the table which match the specified criteria | delete from tablename where condition; | delete from customers where employment_status='terminated'i;
|
| Update | Changes a row or rows from the table which match the specified criteria | update tablename set column1=value1, column2=value2 where condition; | update customers |
| Commit | Commits last set of changes to the database | commit; | commit; |
| Rollback | Abandons last set of changes | rollback; | rollback; |
| Last updated | Please report any problems or comments to matt@mindflip.com |