SQL BASICS Flashcards
(5 cards)
Some of The Most Important SQL Commands
SELECT - extracts data from a database
UPDATE - updates data in a database
DELETE - deletes data from a database
INSERT INTO - inserts new data into a database
CREATE DATABASE - creates a new database
ALTER DATABASE - modifies a database
CREATE TABLE - creates a new table
ALTER TABLE - modifies a table
DROP TABLE - deletes a table
CREATE INDEX - creates an index (search key)
DROP INDEX - deletes an index
IN Operator Example
SELECT name, population FROM world
WHERE name IN (‘Brazil’, ‘Russia’, ‘India’, ‘China’);
or
SELECT * FROM Customers
WHERE Country NOT IN (‘Germany’, ‘France’, ‘UK’);
IN (SELECT) Example
SELECT * FROM Customers
WHERE CustomerID IN (SELECT CustomerID FROM Orders);
DISTINCT Clause
The SELECT DISTINCT statement is used to return only distinct (different/unique- no Duplicate) values.
We use DISTINCT keyword with the SELECT statement when there is a need to avoid duplicate values present in any specific columns/tables. When we use DISTINCT keyword, SELECT statement returns only the unique records available in the table.
SELECT DISTINCT Country FROM Customers;