157A Clauses Flashcards

1
Q

SQL Create

A

CREATE DATABSE database_name;

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

SQL USE

A

USE database_name;

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

SQL DROP

A

DROP DATABASE database_name;

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

SQL CREATE TABLE

In an SQL driven database, the data is stored in a structured manner, i.e. in the form of tables.

A

CREATE TABLE table_name(
column1 dataype,
column2 datatype,
column3 datatype);

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

SQL DESC

Every table in a database has a structure of its own. To display the structure of database tables, we
use the DESC statements.

A

DESC table_name;

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

SQL INSERT INTO

The SQL INSERT INTO Statement is used to insert data into database tables.

A

INSERT INTO database_name(column1, column2, column3) VALUES (data,data,data);

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

SQL SELECT

In order to retrieve the result-sets of the stored data from a database table, we use the SELECT
statement.

A

SELECT * FROM database_name;

or

SELECT column1, column2,column3 FROM table_name;

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

SQL UPDATE

When the stored data in a database table is outdated and needs to be updated without having to
delete the table, we use the UPDATE statement

A

UPDATE database_name SET column1 = value1, column2, value2;

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

SQL DELETE

A

DELETE FROM table_name WHERE (CONDITION)

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

SQL DROP TABLE

A

DROP TABLE table_name;

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

SQL TRUNCATE TABLE

The TRUNCATE TABLE statement is implemented in SQL to delete the data of the table but not the
table itself.

A

TRUNCATE TABLE table_name;

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

SQL ALTER TABLE

The ALTER TABLE statement is used to alter the structure of a table. For instance, you can add, drop,
and modify the data of a column using this statement.

A

ALTER TABLE table_name
{ADD|DROP|MODIFY} column_name {data_type};

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

SQL DISTINCT CLAUSE

The DISTINCT clause in a database is used to identify the non-duplicate data from a column.

A

SELECT DISTINCT column1, column2…columnN FROM table_name;

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

SQL WHERE CLAUSE

the WHERE clause is used to filter rows from a table by applying a condition

A

SELECT * FROM table_name WHERE age > 20;

SELECT column1, column2….columnN
FROM table_name
WHERE CONDITION;

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

SQL AND/OR Operators

The AND/OR Operators are used to apply multiple conditions in the WHERE clause.

A

SELECT column1, column2….columnN
FROM table_name
WHERE CONDITION-1 {AND|OR} CONDITION-2

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

SQL IN Clause

The IN Operator is used to check whether the data is present in the column or not, using the WHERE
clause.

A

SELECT column1, column2….columnN
FROM table_name
WHERE column_name IN (val-1, val-2,…val-N);

17
Q

SQL BETWEEN Clause

The BETWEEN Operator is used to retrieve the values from a table that fall in a certain range, using
the WHERE clause

A

SELECT column1, column2….columnN
FROM table_name
WHERE column_name BETWEEN val-1 AND val-2;

18
Q

SQL LIKE CLAUSE

the like operator is used to retrive the values from the table that match a cretain pattern using the WHERE clause

A

SELECT column1, column2….columnN
FROM table_name
WHERE column_name LIKE { PATTERN };

19
Q

SQL ORDER BY clause

use to arrange values in a specific order

A

SELECT column1, column2, column3 FROM table_name WHERE (CONDITION) ORDER BY column_name{ASC/DESC};

20
Q

SQL GROUP BY clause

The GROUP BY Clause is used to group the values of a column together

A

SELECT SUM(column_name) FROM table_name
WHERE CONDITION
GROUP BY column_name;

21
Q

SQL COUNT function

the COUNT function gives the number of non-null values present in the specified column

A

SELECT COUNT(column_name) FROM table_name WHERE (CONDITION);

22
Q

SQL HAVING clause

The HAVING clause is also used to filter a group of rows by applying a condition.

A

SELECT SUM(column_name) FROM table_name
WHERE CONDITION
GROUP BY column_name
HAVING (arithematic function condition);

23
Q

SQL CREATE INDEX

to create index on a database table. SQL provides the CREATE INDEX statement.

A

CREATE UNIQUE INDEX index_name
ON table_name ( column1, column2,…columnN);

24
Q

SQL DROP INDEX

used to drop an index from a table

A

DROP INDEX sample_index on CUSTOMERS;