SQL Syntax Flashcards

1
Q

SELECT

A

extracts data from a database

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

UPDATE

A

updates data in a database

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

DELETE

A

deletes data from a database

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

INSERT INTO

A

inserts new data into a database

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

CREATE DATABASE

A

creates a new database

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

ALTER DATABASE

A

modifies a database

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

CREATE TABLE

A

creates a new table

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

ALTER TABLE

A

modifies a table

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

DROP TABLE

A

deletes a table

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

CREATE INDEX

A

creates an index (search key)

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

DROP INDEX

A

deletes an index

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

SELECT *

A

selects all the columns from the specific table

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

SELECT DISTINCT

A

select all the different values from the specific columns in specific table,
a column often contains many duplicate values; and sometimes you only want to list the different (distinct) values. NOT LIST DUPLICATE

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

SELECT COUNT

A

lists the number of different (distinct) countries in table ,,,doesNOT work for firefox, NOT supported for MS access databases.

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

SELECT WHERE

A

is used to filter records. is used to extract only those records that fulfill a specified condition. USED in SELECT, UPDATE , DELETE statements.

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

TEXT FIELDS VS NUMBERIC FIELDS

A

TEXT=require single quotes around text values(most database systems will also allow double quotes).
NUMERIC= should NOT be enclosed in quotes

17
Q

Operators in the WHERE Clause

A
=	Equal	
>	Greater than	
<	Less than	
>=	Greater than or equal	
<=	Less than or equal	
<>	Not equal. Note: In some versions of SQL this operator may be written as !=	

BETWEEN Between a certain range

LIKE Search for a pattern

IN To specify multiple possible values for a column

18
Q

The SQL AND , OR and NOT Operators

A

The WHERE clause can be combined with AND, OR, and NOT operators.

The AND and OR operators are used to filter records based on more than one condition:

The AND operator displays a record if all the conditions separated by AND are TRUE.
The OR operator displays a record if any of the conditions separated by OR is TRUE.
The NOT operator displays a record if the condition(s) is NOT TRUE.

19
Q

AND Syntad

A

SELECT column1, column2, …
FROM table_name
WHERE condition1 AND condition2 AND condition3 …;

all conditions must be true

20
Q

OR Syntax

A

SELECT column1, column2, …
FROM table_name
WHERE condition1 OR condition2 OR condition3 …;

atleast one condition must be true

21
Q

NOT Syntax

A

SELECT column1, column2, …
FROM table_name
WHERE NOT condition;

no condition must be true to display

22
Q

Combining AND, OR and NOT

A

You can also combine the AND, OR and NOT operators.

The following SQL statement selects all fields from “Customers” where country is “Germany” AND city must be “Berlin” OR “München” (use parenthesis to form complex expressions):

SELECT * FROM Customers
WHERE Country=’Germany’ AND (City=’Berlin’ OR City=’München’);

The following SQL statement selects all fields from “Customers” where country is NOT “Germany” and NOT “USA”:

Example
SELECT * FROM Customers
WHERE NOT Country=’Germany’ AND NOT Country=’USA’;

23
Q

SQL ORDER BY Keyword

A

The ORDER BY keyword is used to sort the result-set in ascending or descending order.

The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.

SELECT column1, column2, …
FROM table_name
ORDER BY column1, column2, … ASC|DESC;

SEVERAL COLUMNS

SELECT * FROM Customers
ORDER BY Country, CustomerName;

ASC and DESC
SELECT * FROM Customers
ORDER BY Country ASC, CustomerName DESC;