About Me

Thursday, 19 April 2012

SQL - Commands

SQL - Commands

SQL commands are lines of SQL code that ask the SQL application to perform simple tasks against with data inside of a database. Often we refer to commands as query statements or scripts; all of these terms are synonymous. Most of the commands and statements you will see in this tutorial are fairly standard and will work across multiple database applications despite the fact this tutorial is aimed for the SQL Server Express user.


SQL commands are declarative sentences or 'orders' executed against a SQL database. The typical command is comprised of several different components including clauses, functions, expressions, or objects but the only required components are a SQL Clause and the data object (a database or a database table).

SQL - Clauses

A SQL clause is the word or phrase that begins each SQL command statement and the single most important component to any SQL command. Looking at the clause of any given SQL command usually tells the SQL programmer what that particular command intends to do to the database. For instance, a SELECT command begins with the SELECT clause and any level of SQL programmer will recognize the SELECT query as a command selecting data from the database.
Other SQL clauses include:
  • Add
  • Drop
  • Create
  • Insert
  • Select
  • Update
  • Replace
  • Delete

SQL - Sample Commands

SQL Code:

SELECT getdate(); -- Selects the current (server) date and time.

CREATE DATABASE MyDatabase; -- Creates a database named Mydatabase;

INSERT INTO orders 
 -- Inserts data into a database table
VALUES('A+Maintenance','8/16/08','Hanging Files',12);

0 comments:

Post a Comment