MySQL Flashcards

1
Q

What connection method is used for a local MySQL server?

A

Standard TCP/IP.

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

What is the default host name for a local MySQL connection?

A

localhost

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

What is the default port number for MySQL?

A

3306.

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

What SQL command is used to create a database?

A

CREATE DATABASE.

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

How should SQL statements be concluded?

A

With a semicolon.

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

What icon is used to execute a command in MySQL Workbench?

A

The lightning bolt icon.

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

What happens when you refresh the Schemas tab after creating a database?

A

The newly created database will appear.

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

How do you select set a database as the default schema?

A
  1. Right-click on the database
  2. Select ‘set as default schema’.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What command is used to switch to a specific database?

A

USE [database_name];

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

What command is used to drop a database?

A

DROP DATABASE [database_name];

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

What does the ‘sys’ database represent in MySQL?

A

The internal database used by MySQL.

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

What SQL command is used to set a database to read-only mode?

A
ALTER DATABASE [database_name] 
READ ONLY = 1;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What happens when a database is set to read-only mode?

A

Modifications aren’t allowed, but data can still be accessed.

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

What SQL command is used to remove the read-only status of a database?

A
ALTER DATABASE [database_name] 
READ ONLY = 0;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the SQL command to create a table?

A

CREATE TABLE [table_name];

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

What are the components of a table in a relational database?

A

Rows and columns.

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

A folder acts as a ______.

A

container

Tables are like the files contained within that folder.

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

How is MySQL designed to be flexible and user-friendly?

A
  1. In MySQL, keywords like SELECT, FROM, WHERE, and others are not case-sensitive.
  2. This means you can write them in uppercase, lowercase, or a mix of both, and MySQL will interpret them the same way.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What should you do if you want to recreate a database after dropping it?

A

CREATE DATABASE [database_name];

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

What protocols can clients use to connect to MySQL Server?

A

Clients can connect using:

  1. TCP/IP sockets
  2. named pipes (on Windows)
  3. shared memory (on Windows)
  4. Unix domain socket files

Named pipes and shared memory connections require specific server startup configurations.

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

Which programming languages are supported for writing MySQL client programs?

A

C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, Tcl

Client libraries are available for various languages, including C and C++.

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

What is the purpose of the Connector/ODBC interface?

A

(ODBC) is a protocol that you can use to connect a Microsoft Access database to an external data source such as M̶i̶c̶r̶o̶s̶o̶f̶t̶ SQL Server

Open Database Connectivity

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

What does Connector/J support?

A
  1. Connector/J is a Java driver that supports connections to various database engines including MySQL.
  2. It implements the Java Database Connectivity (JDBC) API and extensions to the API

Can be run on both Windows and Unix.

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

What is the function of MySQL Connector/NET?

A

It enables developers to create .NET applications requiring secure, high-performance data connectivity with MySQL implementation.

It is a fully managed ADO.NET driver written in 100% pure C#.

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

How does MySQL support localization?

A

The server can provide error messages in many languages and supports various character sets.

Includes support for Scandinavian characters and several Unicode character sets.

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

What happens to data in MySQL regarding character sets?

A

All data is saved in the chosen character set

Sorting and comparisons are done according to the default character set and collation.

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

How can the server time zone be managed in MySQL?

A

The server time zone can be changed dynamically, and individual clients can specify their own time zone

This provides flexibility in handling time-related data.

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

Name two types of client and utility programs included in MySQL.

A

Command-line programs (e.g., mysqldump, mysqladmin) and graphical programs (e.g., MySQL Workbench)

These programs assist in database management and operations.

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

What built-in support does MySQL Server provide for table management?

A

SQL statements to check, optimize, and repair tables

These statements can be accessed through the mysqlcheck client.

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

What utility is available for performing operations on MyISAM tables?

A

myisamchk

It is a fast command-line utility for managing MyISAM tables.

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

What command can be used to obtain online assistance for MySQL programs?

A

–help or -?

This option provides help information for using MySQL programs.

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

What are two tools that allow the user to type SQL statements?

A

MySQL Workbench and MySQL Command-Line Client

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

What feature does MySQL Workbench have to reduce typing?

A

Automatically generate some SQL statements

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

When are SQL statements executed in MySQL Workbench?

A

When the lightning bolt is clicked

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

What keyboard shortcut executes all SQL statements in MySQL Workbench on Windows?

A

Ctrl+Shift+Enter

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

What keyboard shortcut executes all SQL statements in MySQL Workbench on a Mac?

A

Command+Shift+Enter

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

What does the Navigator sidebar in MySQL Workbench show after connecting to the MySQL server?

A

Browse Documentation and Local instance MySQL8O

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

What administrative options are available in the Administration tab of MySQL Workbench?

A

Checking server’s status, importing/exporting data, starting/stopping the MySQL server

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

What does the Schemas tab show in MySQL Workbench?

A

A list of available databases

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

Fill in the blank: A database can be expanded to show the database’s _______.

A

tables

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

What SQL statement is used to add a new column to an existing table?

A

ALTER TABLE table_name ADD COLUMN column_name data_type constraints;

Replace table_name with the name of your table, column_name with the desired name for the new column, data_type with the appropriate data type (e.g., VARCHAR, INT, DATE), and optionally add constraints.

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

Provide an example of adding a new column to a table.

A

ALTER TABLE Customers ADD COLUMN email VARCHAR(255);

This example adds an ‘email’ column of type VARCHAR with a maximum length of 255 characters to the ‘Customers’ table.

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

What SQL statements is used to modify an existing column’s definition?

A

ALTER TABLE table_name
MODIFY COLUMN column_name new_data_type new_constraints;

or

ALTER TABLE table_name
ALTER COLUMN column_name new_data_type new_constraints;

The choice between MODIFY COLUMN and ALTER COLUMN depends on the specific database system.

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

Provide an example of modifying an existing column.

A
ALTER TABLE Products 
MODIFY COLUMN price DECIMAL(10, 2);

This example modifies the ‘price’ column in the ‘Products’ table to be of type DECIMAL with a precision of 10 and scale of 2.

45
Q

What SQL statement is used to delete a column from a table?

A
ALTER TABLE table_name 
DROP COLUMN column_name; 

This statement removes the specified column from the table.

46
Q

Provide an example of deleting a column from a table.

A
ALTER TABLE Employees 
DROP COLUMN department; 

This example deletes the ‘department’ column from the ‘Employees’ table.

47
Q

What SQL statement is used to add a new row to a table?

A

~~~
INSERT INTO table_name (column1, column2, …) VALUES (value1, value2, …);

This statement is used to insert a new record into the specified table.

48
Q

Provide an example of adding a new row to a table.

A

INSERT INTO Products (name, price, category) VALUES (‘Laptop’, 1200, ‘Electronics’);

This example inserts a new product with the name ‘Laptop’, price of 1200, and category ‘Electronics’ into the ‘Products’ table.

49
Q

Why isn’t the syntax for ALTER TABLE consistent across all database systems?

A

The exact syntax for ALTER TABLE might vary slightly depending on the specific database system being used (e.g., MySQL, PostgreSQL, SQL Server).

50
Q

What should you do before making significant changes to a table?

A

Back up your data

It is recommended to back up your data before modifying existing tables to prevent data loss.

51
Q

It is similar to asking someone to ‘choose’ or ‘identify’.

Example: ‘Select your favorite fruits’ translates to the SQL command SELECT fruits FROM table_name;

A

What does the SQL command SELECT do?

52
Q

It specifies ‘where’ something comes from in a conversation.

Example: ‘From which store did you buy this item?’ corresponds to FROM store_table.

A

What is the purpose of the FROM clause in SQL?

53
Q

It asks for a condition.

Example: ‘Where can I find the red apples?’ translates to WHERE color = 'red'.

A

What does the WHERE clause indicate in SQL?

54
Q

It fetches records that have matching values in both tables.

Comparable to a group coming together to share information.

A

How does INNER JOIN function in SQL?

55
Q

It organizes data.

Example: ‘Can you sort these books by title?’ translates to ORDER BY title.

A

What is the purpose of the ORDER BY clause in SQL?

56
Q

It categorizes items.

Example: ‘Group the apples by their types’ corresponds to GROUP BY apple_type.

A

What does GROUP BY do in SQL?

57
Q

It adds something into a list.

Example: ‘Add this item to my shopping list’ translates to INSERT INTO shopping_list VALUES (...).

A

What does the INSERT INTO command do in SQL?

58
Q

It changes existing data.

Example: ‘Change the address for my subscription’ relates to UPDATE subscriptions SET address = 'new_address'.

A

What is the function of the UPDATE command in SQL?

59
Q

It removes data from a table.

Example: ‘Remove this item from my cart’ translates to DELETE FROM cart WHERE item_id = ....

A

What does the DELETE command do in SQL?

60
Q

Only those items that are unique

Example: SELECT DISTINCT customer_name FROM customers;

A

What does the SQL keyword DISTINCT represent?

61
Q

Filter results after aggregation

Example: HAVING COUNT(item_id) > 5

A

What is the purpose of the HAVING clause in SQL?

62
Q

Find values resembling a pattern

Example: WHERE name LIKE 'John%';

A

What does the LIKE operator do in SQL?

63
Q

Select values within a specified range

Example: WHERE price BETWEEN 10 AND 20

A

What does the BETWEEN operator specify in SQL?

64
Q

Restrict the number of results returned

Example: LIMIT 5

A

What does the LIMIT clause do in SQL?

65
Q

Combine results from two or more queries

Example: SELECT item FROM list1 UNION SELECT item FROM list2

A

What does UNION do in SQL?

66
Q

Include all items from one side regardless of matches

Example: LEFT OUTER JOIN or RIGHT OUTER JOIN

A

What is the function of an OUTER JOIN in SQL?

67
Q

Join tables based on equivalent values

Example: SELECT * FROM students INNER JOIN grades ON students.id = grades.student_id

A

What is an EQUIJOIN?

68
Q

Relate rows within the same table

Example: SELECT a.name, b.name FROM employees a, employees b WHERE a.supervisor_id = b.supervisor_id

A

What does a SELF JOIN achieve in SQL?

69
Q

Combine all possible pairs of rows from two tables

Example: SELECT shirts.color, pants.color FROM shirts CROSS JOIN pants

A

What is the purpose of a CROSS JOIN?

70
Q

Evaluate different conditions and return values

Example: CASE WHEN weather = 'rainy' THEN 'bring umbrella' ELSE 'wear jacket' END

A

What does the CASE statement do in SQL?

71
Q

A query nested inside another query

Example: SELECT name FROM customers WHERE id = (SELECT customer_id FROM orders GROUP BY customer_id ORDER BY COUNT(*) DESC LIMIT 1)

A

What is a SUBQUERY?

72
Q

Remove all records from a table

Example: TRUNCATE TABLE shopping_cart

A

What does the TRUNCATE command do?

73
Q

Create a quick reference guide for faster searches

Example: CREATE INDEX idx_favorite_recipes ON recipes (favorite)

A

What is the purpose of an INDEX in SQL?

74
Q

A reference that links rows in different tables

Example: Links information to a student

A

What is a FOREIGN KEY?

75
Q

The main identifier for records in a table

Example: Uniquely identifies each user by email

A

What is a PRIMARY KEY?

76
Q

Undo the last transaction

Example: Reverse changes if a mistake is made

A

What does ROLLBACK do in SQL?

77
Q

Confirm and save changes made

Example: Save all changes made to the profile

A

What does COMMIT signify in SQL?

78
Q

Remove a table or database entirely

Example: DROP TABLE old_contacts

A

What does DROP do in SQL?

79
Q

Modify an existing database object

Example: ALTER TABLE contacts ADD COLUMN phone_number VARCHAR(15);

A

What is the function of the ALTER command?

80
Q

Change the data type of a value

Example: CAST(number AS VARCHAR)

A

What does CAST do in SQL?

81
Q

What is a database system instance?

A

A single executing copy of a database system.

82
Q

What is the purpose of the CREATE DATABASE statement?

A

Used to create a new database.

83
Q

What does the DROP DATABASE statement do?

A

Deletes a specified database along with its tables.

84
Q

What is the SHOW DATABASES command used for?

A

Lists all databases in the system.

85
Q

What information does the SHOW TABLES command provide?

A

Lists tables in the selected database.

86
Q

What does the SHOW COLUMNS command do?

A

Shows the columns in a specified table.

87
Q

What is the purpose of the SHOW CREATE TABLE command?

A

Displays the SQL command used to create a particular table.

88
Q

What is the function of the USE statement?

A

Required to select the active database before executing other SHOW commands.

89
Q

What algorithm does the InnoDB buffer use?

A

Least Recently Used (LRU) algorithm

This algorithm discards the block that has not been accessed for the longest time.

90
Q

What does architecture describe in the context of MySQL?

A

Components of a computer system and the relationships between components

Other relational databases have similar components, but details and relationships vary.

91
Q

How is Oracle Database different from MySQL in terms of storage engines?

A

Oracle Database has a built-in storage engine that cannot be changed, while MySQL has multiple storage engines

This is considered unusual for relational databases.

92
Q

What are the four main parts organized in MySQL architecture?

A
  1. Tools Layer
  2. Query Processor Layer
  3. Storage Engine Layer
  4. File System Layer
93
Q

What is the role of the query processor?

A

Manages connections and compiles queries

It translates SQL into low-level storage engine instructions.

94
Q

What does a connection in MySQL authorize?

A

A user to access a database

95
Q

What is the main function of the storage engine?

A

Transaction management and data access

96
Q

What does the audit feature in MySQL do?

A

Tracks all database changes, including the time of change and who made the change

97
Q

What are the two main functions of the query processor layer?

A
  1. Manage connections
  2. Compile queries
98
Q

What is an execution plan?

A

A detailed, low-level sequence of steps that specify how to process a query

99
Q

What is the purpose of the cache manager in the query processor layer?

A

Stores reusable information in main memory for optimal performance

100
Q

What components are included in transaction management?

A
  1. Concurrency system
  2. Recovery system
  3. Lock manager
101
Q

What types of data does the file system layer contain for each database?

A
  1. User data
  2. Log files
  3. Data dictionary
102
Q

What does the MySQL data dictionary include?

A

Roughly 30 tables, including tables, table_stats, columns, foreign_keys, indexes, routines, and triggers

103
Q

True or False: InnoDB is the default storage engine in MySQL.

104
Q

Fill in the blank: The _______ manager retains data blocks from the file system for possible reuse.

105
Q

What does the recovery system use to restore data in the event of a failure?

106
Q

What are Connectors and APIs in MySQL?

A

Groups of application programming interfaces linking applications to the query processor layer

107
Q

What is the function of the buffer manager?

A

Retains data blocks in an area of main memory called the buffer

108
Q

What does the query optimizer do?

A

Generates alternative execution plans, estimates execution times, and selects the fastest plan

109
Q

What is the primary role of utility programs in MySQL?

A

Perform various administrative functions such as upgrading databases, backing up, and importing data