Languages

SQL Tutorial

SQL in DatAdmin

This chapter explains, how to run queries in DatAdmin console with chinook sample database. If you are allready using other SQL console with chinook database, you can go to next chapter.

How to run query on sample database in DatAdmin

In connection tree, there is folder "Samples", chinook-sqlite.db3 is sample database chinook. Use "Connect" in context menu, than "Query".

DatAdmin - how to open query window

SQL changing data

There are three basic data changing SQL statements:

  • UPDATE
  • DELETE
  • INSERT

Some database engines support other additional commands (eg. MySQL - REPLACE)

UPDATE - changing existing data

UPDATE command modifies data in existing rows.

Syntax:

UPDATE table_name SET column1=value1[, column2=value2...] WHERE condition

Examples:

UPDATE Customer SET Country = 'United States' WHERE Country = 'USA'
UPDATE Customer SET FirstName = 'John' WHERE CustomerId = 17

SQL Relations

Primary key is identifier of row in table. Foreign key is reference from one table to primary key of other table. SQL JOIN keyword is used to query data from two ore more tables, using relation columns.

SQL Where

The WHERE clause is used for filtering rows.

Simplified syntax is:

SELECT column(s) FROM table WHERE column_name operator value

Standard SQL support these operators:

SQL Basics, SELECT, Ordering

Database constists of tables. Table is collections of rows, every row has one or more columns. Below is Genre table from Chinook sample database:

SQL Tutorial

This tutorial shows basic information about SQL. All examples you can try with DatAdmin on chinook database, which is by default part of DatAdmin installation.

Syndicate content