SQL BASICS Flashcards

(5 cards)

1
Q

Some of The Most Important SQL Commands

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

IN Operator Example

A

SELECT name, population FROM world
WHERE name IN (‘Brazil’, ‘Russia’, ‘India’, ‘China’);

or

SELECT * FROM Customers
WHERE Country NOT IN (‘Germany’, ‘France’, ‘UK’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

IN (SELECT) Example

A

SELECT * FROM Customers
WHERE CustomerID IN (SELECT CustomerID FROM Orders);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

DISTINCT Clause

A

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;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly