The statement starts with the keyword "CREATE" followed by "DATABASE", indicating that a new database will be created. "friends" is the name of the new database being created:
mysql> CREATE DATABASE friends;
Query OK, 1 row affected (0.11 sec)
mysql>
Once the statement is executed, MySQL responds with a message that indicates the query was successful, with "Query OK" and the number of rows affected (in this case, 1).
The time taken to execute the statement is also displayed in seconds (in this case, 0.11 seconds).
In summary, the code creates a new MySQL database called "friends".
mysql> CREATE DATABASE stamps;
Query OK, 1 row affected (0.12 sec)
mysql>
This is a MySQL command to create a new database named "stamps". The syntax for creating a new database in MySQL is:
CREATE DATABASE database_name;
Here, "stamps" is the name of the new database to be created.
The output "Query OK, 1 row affected (0.12 sec)" indicates that the execution of the CREATE DATABASE command was successful and it created the new database named "stamps".
mysql> USE friends;
Database changed
mysql>
This command is used to select a specific database to work with in MySQL. In this case, the command is "USE friends;", which is selecting the "friends" database.
After executing this command, any subsequent SQL queries will be performed on the "friends" database until a different database is specified with another USE command or the connection is closed.
The output of the command is "Database changed", which indicates that the switch to the "friends" database was successful.
mysql> SHOW TABLES FROM friends;
Empty set (0.00 sec)
mysql>
The SHOW TABLES
command is used to display the list of tables in a specific database.
In this case, we switched to the friends
database using the USE
command, and then ran the SHOW TABLES
command to check if there were any tables in the friends
database. The output shows that there were no tables in the friends
database yet, hence the "Empty set" message.
mysql> DROP DATABASE friends;
Query OK, 0 rows affected (0.13 sec)
mysql>
This command will drop (delete) the "friends" database from the MySQL server. It is accomplished by executing the DROP DATABASE statement, followed by the name of the database to be dropped.
In this case, the "friends" database has been dropped successfully, as indicated by the "Query OK" message with 0 rows affected.
mysql> DROP DATABASE stamps;
Query OK, 0 rows affected (0.13 sec)
mysql>
The command "DROP DATABASE" is used to delete a database and all its related objects permanently. In this case, the "stamps" database was created earlier using the command "CREATE DATABASE".
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql>
Return to situation before we created custom databases.
No comments:
Post a Comment