WEEK 4 Flashcards

(22 cards)

1
Q

Answer: SQL stands for Structured Query Language and is a query language used to manage and manipulate relational databases.

A

Question: What is SQL?

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

Question: What is the difference between DDL and DML?

A

Answer: DDL stands for Data Definition Language and is used to define the structure and schema of a database. DML stands for Data Manipulation Language and is used to manipulate the data stored in a database.

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

Question: What does the SQL statement “SELECT * from product;” do?

A

Answer: This SQL statement selects all columns and rows from the “product” table.

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

Question: What does the * symbol represent in the SQL statement “SELECT * from product;”?
.

A

Answer: The * symbol represents all columns in the specified table

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

Question: How can you select only specific columns in a SQL query?

A

Answer: You can specify the column names in the SELECT statement instead of using the * symbol.

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

Question: What is the purpose of the “–” symbol in SQL?

A

Answer: The “–” symbol is used to indicate a comment in SQL code.

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

Question: What are logical operators in SQL?

A

Answer: Logical operators are used in SQL to combine conditions in a query. The two most common operators are “AND” and “OR”.

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

Question: How can you concatenate two columns in a SQL query?

A

Answer: You can concatenate two columns by using the + operator in between them, like this: SELECT CUS_FNAME +’ ‘+ CUS_LNAME FROM CUSTOMER;

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

Question: What is the purpose of the DISTINCT keyword in SQL?

A

Answer: The DISTINCT keyword is used to remove duplicates from the results of a query and only show unique values.

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

Question: How can you order the results of a SQL query?

A

Answer: You can use the ORDER BY keyword followed by the column name to sort the results of a query. By default, the results are sorted in ascending order, but you can add the “DESC” keyword to sort in descending order.

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

Question: What is the purpose of the BETWEEN keyword in SQL?

A

Answer: The BETWEEN keyword is used to filter results within a specified range of values.

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

What is DML?

.

A

Answer: DML is a data manipulation language used to insert, update, delete, and retrieve information

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

What is DDL?

A

Answer: DDL is a data definition language used to create objects (tables, indexes, views) and access rights (users).

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

What is TCL?

A

Answer: TCL is a transaction control language.

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

What is DCL?

A

Answer: DCL is a data control language used for user permission - who can do what.

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

What are some data types?

A

Answer: Data types include character (string), numeric (int, float), date/time, boolean (yes/no), and GUID.

17
Q

What is the syntax for the SELECT keyword?

A

Answer: The syntax for the SELECT keyword is SELECT (data fields) FROM (tablename).

18
Q

What is an alias in SQL?

A

Answer: An alias in SQL is used to make field names prettier. It is a syntax that allows you to rename a column in a table with another name.

19
Q

To create a table, you
will need:

A
  1. A table name
  2. Names for all
    columns
  3. Data type for each
    column
  4. Applicable
    constraints
20
Q

DDL (Data Definition Language) commands:

A

NOT NULL
PRIMARY KEY
FORIEGN KEY
DEFAULT
CHECK
CREATE: used to create a new database object such as a table, index, view, or stored procedure.
ALTER: used to modify the structure of an existing database object.
DROP: used to delete an existing database object.
TRUNCATE: used to delete all the data from a table without deleting the table structure.
RENAME: used to rename an existing database object.
GRANT: used to grant specific privileges to a user or role.
REVOKE: used to revoke privileges that were previously granted.

21
Q

DML (Data Manipulation Language) commands:

A

SELECT: used to retrieve data from a database table.
INSERT: used to insert new data into a database table.
UPDATE: used to modify existing data in a database table.
DELETE: used to delete data from a database table.
MERGE: used to combine data from two tables into a single table.
CALL: used to execute a stored procedure or function.
LOCK: used to lock a table or row to prevent other users from modifying the data.

22
Q

Character: This data type is used to store strings of characters, such as names, addresses, and other textual data. The maximum length of a character data type is determined by the database system.

Numeric: This data type is used to store numeric data, such as integers or decimal numbers. There are different types of numeric data types in SQL, such as INTEGER, SMALLINT, BIGINT, DECIMAL (L,D), and FLOAT.

Date/time: This data type is used to store date and time data. The SQL standard defines two data types for date/time data: DATE for storing dates and TIMESTAMP for storing both dates and times.

A

Character: This data type is used to store strings of characters, such as names, addresses, and other textual data. The maximum length of a character data type is determined by the database system.

Numeric: This data type is used to store numeric data, such as integers or decimal numbers. There are different types of numeric data types in SQL, such as INTEGER, SMALLINT, BIGINT, DECIMAL, and FLOAT.

Date/time: This data type is used to store date and time data. The SQL standard defines two data types for date/time data: DATE for storing dates and TIMESTAMP for storing both dates and times.