Database Learning (3)-database creation and Deletion

Source: Internet
Author: User

Database Learning (3) -- database creation and deletion (2) -- SQL language Overview http://www.bkjia.com/database/201305/207487.html In the subsequent operations section, we recommend that you install MySQL for your convenience. The installation of the new MySQL version is simple, and the basic default settings are enough. Before creating or deleting a database, you must create a database. Only when a database is created can a data table be created in the database. If the database is no longer needed, you can delete it. This chapter describes how to create and delete SQL statements in the MySQL 5.0 Command Line Client window and the user interface of MySQL5.0. Before creating a data table, use SQL statements to create a database. Only when a database is created can a data table be created in the database. The syntax for creating a DATABASE is as follows: create database database_name use the create database statement to CREATE a DATABASE. The create database keyword is used to CREATE a DATABASE. database_name indicates the name of the DATABASE to be created. The create database statement is followed by the DATABASE name. Create a database in the MySQL 5.0 Command Line Client window. The following uses the MySQL 5.0 database as an example. Let's take a look at how to create a database in the MySQL Command Line Client window, use the create database statement to CREATE the test_STInfo DATABASE. (1) Click "start" | "All Programs" | "MySQL 5.0" | "MySQL 5.0 Command Line Client. After running, enter the password in the MySQL 5.0 Command Line Client window that appears. The password is root. (2) Use the create database statement to CREATE the test_STInfo DATABASE in the MySQL 5.0 Command Line Client window, and end the SQL statement with a semicolon. (3) Click "Enter" to execute the SQL statement for creating the database. The execution result is as follows. Note: When you use the MySQL 5.0 Command Line Client window to write an SQL statement, you must add a semicolon (;) to the end of the SQL statement. Otherwise, the SQL statement cannot be correctly executed. As you can see, after using the create database statement to CREATE the test_STInfo DATABASE, the following information is output under the SQL statement of the DATABASE it creates: Query OK, 1 row affected (0.00 sec) this output indicates that a row of data has changed in MySQL 5.0, indicating that the SQL statement used to CREATE the test_STInfo DATABASE by the CREATE DATABASE statement has been correctly executed. To check whether the database test_STInfo has been created, double-click my computer and go to the C: \ Program Files \ MySQL Server 5.0 \ data directory, you can see that there is an additional test_STInfo folder under this directory, indicating that the test_STInfo database has been created. Create a database in the MySQL5.0 user interface. Of course, in addition to creating a database in the MySQL 5.0 Command Line Client window, you can also directly create a database in the MySQL5.0 user interface of MySQL5.0. You can delete a DATABASE by using drop database in SQL statements. In addition, different database management systems also provide methods to delete databases. This section uses the MySQL5.0 database as an example to describe how to delete a database in the MySQL5.0 database. If you want to delete a database by using an SQL statement, you can use the DROP DATEBASE statement to delete it. The syntax rules are as follows: drop database database_name where drop datebase indicates the keyword used to delete the DATABASE; database_name indicates the name of the DATABASE to be deleted. For example, if you want to delete the test_STInfo database, you can use the following SQL statement. In the MySQL 5.0 Command Line Client window, delete a DATABASE. In the MySQL 5.0 Command Line Client window, use the drop database statement to delete the test_STInfo DATABASE, the SQL statement is followed by a semicolon. The following information is output under the SQL statement used to delete the database: Query OK, 0 row affected (0.16 sec). to check whether the database test_STInfo has been successfully deleted, you can double-click my computer and enter the C: \ Program Files \ MySQL Server 5.0 \ data directory, we can see that the test_STInfo folder in this directory has disappeared, indicating that the test_STInfo database has been deleted and deleted in the MySQL5.0 graphic interface (1) in the database corresponding to the Schemata option on the right of the MySQL5.0 user interface, the created test_STInfo database is displayed. (2) Right-click the test_STInfo database and select the "Drop Schema" command in the displayed list box. (3) In the displayed confirm deletion dialog box, click "OK" to delete the test_STInfo database.
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.