Basic SQL Flashcards

1
Q

Name 6 aggregate functions

A
COUNT()
SUM()
MAX()
MIN()
AVG()
ROUND()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Whats the syntax for creating a primary key?

A
ALTER TABLE table
ADD CONSTRAINT constraintName
PRIMARY KEY (colName)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Whats the syntax for creating a foreign key?

A
ALTER TABLE table1
ADD CONSTRAINT constraintName
FOREIGN KEY (foreignkey_table1_Name)
REFERENCES table2 (foreignkey_table2_Name);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Whats the syntax for dropping a constraint?

A

ALTER TABLE tableName

DROP CONSTRAINT constraintName;

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

How do you get the current date?

A

SYSDATE

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

Whats the syntax for using the substr() function?

A

SUBSTR(string, startPosition, length)

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

Whats the syntax for using the concat() function?

A

CONCAT(str1, str2)

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

Whats the syntax for creating a table?

A

CREATE TABLE table_name (
column1 datatype,
column2 datatype
);

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

Whats the syntax for inserting a row into a table?

A

INSERT INTO table_name

VALUES (value1, value2);

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

Whats the syntax for deleting a row into a table?

A

DELETE FROM table_name WHERE condition;

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

Whats the syntax for updating a row(s) in table?

A

UPDATE table_name
SET column = value
WHERE condition;

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