Other Functions Flashcards

1
Q

AND / OR

A

SELECT column_name(s)
FROM table_name
WHERE condition
AND|OR condition

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

ALTER TABLE

A
ALTER TABLE table_name
ADD column_name datatype
or
ALTER TABLE table_name
DROP COLUMN column_name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

AS (alias)

A
SELECT column_name AS column_alias
FROM table_name
or
SELECT column_name
FROM table_name AS table_alias
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Between

A

SELECT column_name(s)
FROM table_name
WHERE column_name
BETWEEN value1 AND value2

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

CREATE index

A
CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
...
)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

CREATE VIEW

A

CREATE VIEW view_name AS
SELECT column_name(s)
FROM table_name
WHERE condition

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

DELETE

A
DELETE FROM table_name
WHERE some_column=some_value
or
DELETE FROM table_name
(Note:Deletes the entire table!!)
DELETE * FROM table_name
(Note:Deletes the entire table!!)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

DROP DATABASE

A

DROP DATABASE database_name

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

EXISTS

A
IF EXISTS (SELECT * FROM table_name WHERE id = ?)
BEGIN
--do what needs to be done if exists
END
ELSE
BEGIN
--do what needs to be done if not
END
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

GROUP BY

A

SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name

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

HAVING

A

SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value

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

IN

A

SELECT column_name(s)
FROM table_name
WHERE column_name
IN (value1,value2,..)

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

INSERT INTO

A
INSERT INTO table_name
VALUES (value1, value2, value3,....)
or
INSERT INTO table_name
(column1, column2, column3,...)
VALUES (value1, value2, value3,....)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

INNER JOIN

A

SELECT column_name(s)
FROM table_name1
INNER JOIN table_name2
ON table_name1.column_name=table_name2.

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

LEFT JOIN

A

SELECT column_name(s)
FROM table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.

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

RIGHT JOIN

A

SELECT column_name(s)
FROM table_name1
RIGHT JOIN table_name2
ON table_name1.column_name=table_name2.

17
Q

FULL JOIN

A

SELECT column_name(s)
FROM table_name1
FULL JOIN table_name2
ON table_name1.column_name=table_name2.

18
Q

LIKE

A

SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern

19
Q

SELECT

A

SELECT column_name(s)
FROM table_name
ORDER BY column_name [ASC|DESC]

20
Q

SELECT *

A

SELECT *

FROM table_name

21
Q

SELECT DISTINCT

A

SELECT DISTINCT column_name(s)

FROM table_name

22
Q

SELECT INTO

A

SELECT *
INTO new_table_name [IN externaldatabase]
FROM old_table_name
or
SELECT column_name(s)
INTO new_table_name [IN externaldatabase]
FROM old_table_name

23
Q

SELECT TOP

A

SELECT TOP number|percent column_name(s)

FROM table_name

24
Q

TRUNCATE TABLE

A

TRUNCATE TABLE table_name

25
Q

UNION

A
SELECT column_name(s) FROM table_name1
UNION
SELECT column_name(s) FROM table_name2
26
Q

UNION ALL

A
SELECT column_name(s) FROM table_name1
UNION ALL
SELECT column_name(s) FROM table_name2
27
Q

UPDATE

A

UPDATE table_name
SET column1=value, column2=value,…
WHERE some_column=some_value

28
Q

WHERE

A

SELECT column_name(s)
FROM table_name
WHERE column_name operator value