Miscaleneous commands Flashcards

1
Q

What command displays all currently existing databases in MySQL?

A

SHOW DATABASES;

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

What is the purpose of the SHOW DATABASES command?

A

To list all databases available in the MySQL server.

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

What command selects a specific database to work with?

A

USE database_name;

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

Why is the USE command important?

A

It tells MySQL which database to run queries against.

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

What command displays all keys in a table?

A

SHOW * KEYS FROM table_name;

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

What is the purpose of SHOW * KEYS FROM table_name?

A

To display information about the indexes (keys) in a table.

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

Which command lists all databases?

A

SHOW DATABASES;

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

Which command selects the database to use?

A

USE database_name;

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

Which command displays keys in a table?

A

SHOW * KEYS FROM table_name;

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

If you want to check which databases exist before creating a new one, what should you do?

A

Use the SHOW DATABASES command.

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

If you are working in the wrong database, how do you switch to the correct one?

A

Use the USE command with the correct database name.

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

If you need to review the indexes in a table for optimization, which command do you use?

A

SHOW * KEYS FROM table_name;

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

Spot the mistake: ‘SHOW DATABASE database_name;’

A

Correct syntax is: SHOW DATABASES;

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

Spot the mistake: ‘USE database name;’

A

No space allowed. Correct syntax is: USE database_name;

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

Explain the importance of using the correct database with the USE command.

A

It ensures that all your queries are executed in the intended database, preventing accidental changes elsewhere.

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

Describe when you would use SHOW * KEYS FROM table_name.

A

When you want to see the indexes and keys defined on a table, which can help with query optimization.

17
Q

What happens if you run queries without selecting a database first?

A

MySQL will return an error saying ‘No database selected.’

18
Q

Why is it good practice to check existing databases before creating a new one?

A

To avoid naming conflicts and unnecessary duplication.