SQL queries. DML (Data Manipulation Language)

11.4.2.4 describe the basic SQL queries for working with one table in a database: SELECT, UPDATE, INSERT and DELETE

11.4.2.5 use SQL SELECT for data selection in more tables

SQL queries. Data Manipulation Language.

Data Manipulation Language (DML) is a computer language including commands permitting users to manipulate data in a database.

 

The SQL SELECT Statement

The SELECT statement is used to select data from a database.

Syntax Example
SELECT column1, column2, ...
FROM table_name;
SELECT surname, firstname
FROM users;
SELECT column1, column2, ...
FROM table_name
WHERE condition;
SELECT surname, firstname, iin 
FROM users
WHERE userID=5;

Additionally: SQL ORDER BY KeywordSQL AND, OR and NOT Operators

The SQL INSERT Statement

The INSERT command is used to enter records into a table. Values are entered to the table corresponding order to the listed columns.

Syntax Example
INSERT INTO tablename (field1, field2, ...) 
VALUES ('value1', 'value2', ...);
INSERT INTO users (surname, firstname,
address, age)
VALUES ('Aliyev', 'Ruslan', 'Konaev dist. 7-15', 15);
INSERT INTO tablename 
VALUES ('value1', 'value2', ...);
INSERT INTO users 
VALUES (userID, 'Aliyev', 'Ruslan', 'Konaev dist. 7-15', 15);

SQL UPDATE Statement

The UPDATE statement is used to modify the existing records in a table.

Syntax Example
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
UPDATE users
SET surname = "Makeev", firstname = "Maksim"
WHERE userID = 67;

SQL DELETE Statement

The DELETE statement is used to delete existing records in a table.

Syntax Example
DELETE FROM table_name WHERE condition; DELETE FROM users WHERE iin = "950210350464";

 


Questions:


Exercises:

Ex. 1  (Author: Litvinova Olga - CS teacher of NIS Pavlodar)

Ex. 2

Test SELECT (Ex. 1-3) on w3schools.com

Test WHERE (Ex. 1-5) on w3schools.com

Test INSERT on w3schools.com

Test UPDATE (Ex. 1-3) on w3schools.com

Test DELETE (Ex. 1-2) on w3schools.com

Ex. 3

SQLZOO - TASK 1 "SELECT basics

SQLZOO - TASK 2 "SELECT from WORLD"

SQLZOO - TASK 3 "SELECT from Nobel"

Ex. 4

SELECT QUIZ 1

BBC QUIZ 2

Nobel QUIZ 3

Ex. 5

Ex. 6

https://www.101computing.net/sql/sql-1.html

Ex. 7 (Author: Ermekova Ainagul - CS teacher of NIS Pavlodar)


Exam questions:


 

Категория: Relational databases | Добавил: bzfar77 (10.11.2020)
Просмотров: 266 | Теги: Select, update, DML, database, query, INSERT, Delete | Рейтинг: 5.0/1
Всего комментариев: 0
avatar