Black friday

Save big!

All courses under $5 - for a limited time!

Code has been added to clipboard!

How Do SQL Commands Work

Reading time 2 min
Published Jan 3, 2016
Updated Oct 3, 2019

SQL commands are clear, declarative statements. SQL syntax is easy to understand, and managing data in SQL databases accurately and consistently is not a big challenge.

SQL commands are not case-sensitive, and that makes them even more convenient. Small errors like wrong capitalization won’t break your script. However, it’s a common practice to write the statements in all caps to ensure better readability. We will use this approach in our tutorials as well.

SQL Commands: Main Tips

  • To interact with SQL databases, you need to use SQL commands (also called SQL statements).
  • Databases are tables that consist of columns (they represent attributes of an entry) and rows (they represent individual data entries).
  • SQL is not case-sensitive, but writing SQL commands in ALL CAPS improves readability of your code.
  • Certain databases may require a semicolon (;) after each statement. Usually this rule applies when you need to enter a few statements in a single call to the server.

SQL Statement Syntax Example

Let's try performing one of the most common actions in SQL – selecting certain data.

For our example, we are using a demo database, and we want to get all the records from the Customers table.

The following SQL command is all you need for this task.

Example
SELECT * FROM Customers;

Note: The asterisk (*) is an operator to select all the entries from the specified table.

Theory is great, but we recommend digging deeper!

SQL Syntax Cheet Sheet

  • SELECT – selects data from the database.
  • DELETE – removes data from the database.
  • UPDATE – overwrites data in the database.
  • CREATE DATABASE – creates a new database.
  • INSERT INTO – uploads new data into the database.
  • CREATE TABLE – creates a new table.
  • ALTER DATABASE – changes the attributes, files or filegroups of the database.
  • CREATE INDEX – creates an index, or a search key.
  • DROP INDEX – deletes an index.
  • ALTER TABLE – changes the attributes or entries of a table.

SQL Commands: Summary

  • SQL commands, or SQL statements, are used to interact with SQL databases.
  • Databases consist of columns (attributes of entries) and rows (individual data entries).
  • Usually SQL commands are written in all caps for better readability, but SQL is not case-sensitive and all capitalization options work equally.
  • You may need to use a semicolon (;) after each statement for some databases.