MySQL Flashcards
(305 cards)
What SQL command is used to create a database?
CREATE DATABASE.
How should SQL statements be concluded?
With a semicolon.
To create an Index you would use:
To create an composite Index you would use:
To Delete an Index you would use:
What happens when you refresh the Schemas tab after creating a database?
The newly created database will appear.
What command is used to switch to a specific database?
USE [database_name];
What command is used to drop a database?
DROP DATABASE [database_name];
What SQL command is used to set a database to read-only mode?
ALTER DATABASE [database_name] READ ONLY = 1;
What happens when a database is set to read-only mode?
Modifications arenβt allowed, but data can still be accessed.
What SQL command is used to remove the read-only status of a database?
ALTER DATABASE [database_name] READ ONLY = 0;
What is the SQL command to create a table?
CREATE TABLE [table_name];
What are the components of a table in a relational database?
Rows and columns.
How is MySQL designed to be flexible and user-friendly?
- In MySQL, keywords like
SELECT
,FROM
,WHERE
, and others are not case-sensitive. - This means you can write them in uppercase, lowercase, or a mix of both, and MySQL will interpret them the same way.
What should you do if you want to recreate a database after dropping it?
CREATE DATABASE [database_name];
What are the two client and utility program types included in MySQL.
- Command-line programs (e.g., mysqldump, mysqladmin)
- Graphical programs (e.g., MySQL Workbench)
These programs assist in database management and operations.
What built-in support does MySQL Server provide for table management?
SQL statements to check, optimize, and repair tables
These statements can be accessed through the mysqlcheck client.
What command can be used to obtain online assistance for MySQL programs?
--help
or -h
This option provides help information for using MySQL programs.
What SQL statement is used to add a new column to an existing table?
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.
ALTER TABLE table_name ADD COLUMN column_name data_type constraints;
Provide an example of adding a new column to a table.
This example adds an βemailβ column of type VARCHAR with a maximum length of 255 characters to the βCustomersβ table.
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.
What SQL statements is used to modify an existing columnβs definition?
The choice between MODIFY COLUMN and ALTER COLUMN depends on the specific database system.
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;
Provide an example of modifying an existing column.
This example modifies the βpriceβ column in the βProductsβ table to be of type DECIMAL with a precision of 10 and scale of 2.
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. π
What SQL statement is used to delete a column from a table?
ALTER TABLE table_name DROP COLUMN column_name;
This statement removes the specified column from the table.
Provide an example of deleting a column from a table.
This example deletes the βdepartmentβ column from the βEmployeesβ table.
ALTER TABLE Employees DROP COLUMN department;
This example deletes the βdepartmentβ column from the βEmployeesβ table.