Detailed description of the correct MySQL database application solution

Source: Internet
Author: User

The following articles mainly describe the correct operation steps of the MySQL database, including the query statements, the correct operation steps for creating the MySQL database, and the actual operation procedures for creating tables, the following is a detailed description of the specific content. I hope you will find some gains.

Note that the displayed results of all examples are the results of the following steps in order.

Query statement

1. view the MySQL database version number and the current server date.

 
 
  1. MySQL (the best combination with PHP)> select version (), current_date; Operation Method 1)
  2. MySQL (best combination with PHP)> select version ()
  3. ->, Current_date; Operation Method 2)

The operation statements are separated by commas (,) and separated by commas (;). line breaks do not affect the operation.

2. view all databases on the server

 
 
  1. MySQL (the best combination with PHP)> show databases;

Create a database

1. Of course, the MySQL database name "asb" cannot already exist)

 
 
  1. MySQL (the best combination with PHP)> create database asb;

2. Select a database to make it the database for the current operation

 
 
  1. MySQL (best combination with PHP)> use asb;

After the selection is successful, the following information is displayed:

 
 
  1. Database changed 

You can even directly select the database to be operated when logging on to the MySQL (the best combination with PHP) database by using window commands. The premise is that the asb database exists)

 
 
  1. Bin> MySQL (best combination with PHP) asb-u uesername-p
  2. Enter password :******

3. view the name of the currently operated MySQL database

 
 
  1. MySQL (the best combination with PHP)> select database ();

The result is as follows:

 
 
  1. +------------+  
  2. | database() |  
  3. +------------+  
  4. | asb |  
  5. +------------+  
  6. 1 row in set (0.00 sec) 

Create a table

1. use "create table" to create a table. If not, use 'use' to select the database to create the table)

 
 
  1. MySQL (best combination with PHP)> create table emp (emp_id varchar (6)
  2. ->, Emp_name varchar (10)
  3. ->, Emp_age int
  4. ->, Emp-sal int
  5. ->, Emp_bir date
  6. ->, Emp_sex varchar (5)
  7. -> );

2. Check the tables in the current MySQL database to check whether the "emp" table in the previous example has been successfully created)

MySQL (the best combination with PHP)> show tables;

If it is successful, it will be shown as follows:

 
 
  1. +---------------+  
  2. | Tables_in_asb |  
  3. +---------------+  
  4. | emp |  
  5. +---------------+  
  6. 1 row in set (0.00 sec) 

3. view the data table structure

 
 
  1. MySQL (the best combination with PHP)> describe emp;

The running result is shown as follows:

 
 
  1. +----------+-------------+------+-----+---------+-------+  
  2. | Field | Type | Null | Key | Default | Extra |  
  3. +----------+-------------+------+-----+---------+-------+  
  4. | emp_id | varchar(6) | YES | | NULL | |  
  5. | emp_name | varchar(10) | YES | | NULL | |  
  6. | emp_age | int(11) | YES | | NULL | |  
  7. | emp_sal | int(11) | YES | | NULL | |  
  8. | emp_bir | date | YES | | NULL | |  
  9. | emp_sex | varchar(5) | YES | | NULL | |  
  10. +----------+-------------+------+-----+---------+-------+ 

The above content is an introduction to MySQL database operations. I hope you will have some gains.

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.