December 11 Learn MySQL Note finishing

Source: Internet
Author: User

Manage MySQL
Note: Anti-quotes are symbols that are introduced to differentiate between the MySQL keyword and the normal character, and the general table name and field names use the inverse quotation marks.

Common commands
1. Use the database using the database name
2. Display database show databases;
3. Show data sheet show tables;
4. Show field name Show columns form data table name
5. Display query Information show index from data table
6. Creating a Database Create database name
7. Delete database drop database name
8. Create a data table
CREATE table if not EXISTS name (
table field Name Type definition
PRIMARY KEY (table field name)
) engine= DEFAULT Charset=utf8;
For example:
Mysql> CREATE TABLE Runoob_tbl (
-runoob_id INT not NULL auto_increment,
-Runoob_title VARCHAR (+) not NULL,
-Runoob_author VARCHAR (+) not NULL,
-Submission_date Date,
PRIMARY KEY (runoob_id)
) Engine=innodb DEFAULT Charset=utf8;
9. Delete data table drop data table name
10. Inserting data insert into data table name (field name, field name, field name)
VALUES
(VALUE1,VALUE2,VALUE3);
11. Querying data
SELECT Column_name,column_name
From table_name
[WHERE Clause]
[LIMIT N] [OFFSET M];
NOTE: Available * Instead of other fields
You can use the WHERE statement to include any condition.
You can use the LIMIT property to set the number of records returned.
You can specify the data offset for the SELECT statement start query by using offset. By default, the offset is 0.
PHP related to MySQL

Mysqli_query (connection,   query,   resultmode)

This function is used to execute SQL commands
1.PHP script connection to MySQL
Mysqli_connect (    host ,   username,     password,   dbname,  port,      socket)
             host name or IP address   MySQL user name    password        Database     port number   socket or named pipe to use
  Successful link returns connection identity, Failure returns false
2. Disconnecting
Mysqli_close (Mysqli $link) The
usually does not need to use Mysqli_close (), because an open non-durable connection automatically shuts down after the script executes
3. Operations such as creating/deleting a database
Mysqli_query (connection,   query,   resultmode)
               MySQL connection   query string    Optional mode
When you delete a database with a PHP script, there is no confirmation that the information is deleted and the specified database is deleted directly
4. Select Database
Mysqli_select_ DB (Connection,dbname)
5. Use PHP script to get data
Use the PHP function's mysqli_query () and the SQL SELECT command to get the data. The
Mysqli_fetch_array () function takes a row from the result set as an associative array, or a numeric array, or both
returns an array based on the rows taken from the result set, and returns False if there are no more rows.

December 11 Learning MySQL notes collation

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.