SQL Flashcards
SQL is a standard language for _____________ in databases.
storing, manipulating and retrieving data
SQL stands for ___________
Structured Query Language
RDBMS stands for _________________
Relational Database Management System.
Most of the actions you need to perform on a database are done with ____________
SQL statements.
SELECT * FROM Customers;
___ - extracts data from a database
____ - updates data in a database
____ - deletes data from a database
______ - inserts new data into a database
______ - creates a new database
SELECT
UPDATE
DELETE
INSERT INTO
CREATE DATABASE
___ - modifies a database
____ - creates a new table
____ - modifies a table
____ - deletes a table
____ - creates an index (search key)
_______ - deletes an index
ALTER DATABASE
CREATE TABLE
ALTER TABLE
DROP TABLE
CREATE INDEX
DROP INDEX
The _____ statement is used to select data from a database.
SELECT
Syntax of Select:
SELECT column1, column2, …
FROM table_name;
SELECT CustomerName, City FROM Customers;
If you want to return all columns, without specifying every column name, you can use the ______ syntax
SELECT *
SELECT * FROM Customers;
The ________statement is used to return only distinct (different) values.
SELECT DISTINCT
The ____ clause is used to filter records.
WHERE
SELECT * FROM Customers
WHERE Country=’Mexico’;
The ____ BY keyword is used to sort the result-set in ascending or descending order.
ORDER
SELECT * FROM Products
ORDER BY Price;
The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the ___ keyword.
DESC
SELECT * FROM Products
ORDER BY Price DESC;
For ____ values the ORDER BY keyword will order alphabetically:
string
To sort the table reverse alphabetically, use the ___ keyword:
DESC
SELECT * FROM Products
ORDER BY ProductName DESC;
Using Both ASC and DESC:
SELECT * FROM Customers
ORDER BY Country ASC, CustomerName DESC;
The WHERE clause can contain one or many ____ operators.
AND/OR
The AND operator is used to ____ records based on more than one condition, like if you want to return all customers from Spain that starts with the letter ‘G’:
filter
SELECT * FROM Customers
WHERE Country = ‘Spain’ AND CustomerName LIKE ‘G%’;
OR operator syntax
SELECT *FROM Customers
WHERE Country = ‘Germany’ OR Country = ‘Spain’;
The ____ operator is used in combination with other operators to give the opposite result, also called the negative result.
NOT
SELECT * FROM Customers
WHERE NOT Country = ‘Spain’;