MySQL Database common operation collation

Source: Internet
Author: User

Note: MySQL database is a very lightweight database management system, compared to large-scale database management system such as oracle,mysql more lightweight, flexible, fast development features, more suitable for small and medium-sized data storage and architecture. This is why MySQL can be used by tens of thousands of websites. Advanced applications such as cursors, triggers, transactions, and stored procedures have been supported since the 5 release, adding important weights to MySQL's ease-of-use and enterprise service development. Database is very basic, but the performance of the database optimization is the most important, so much optimization, it will be beneficial.

0. User Management

1.

I. Database operations

1. View the database

SHOW DATABASES;

2. Create a database

CREATE DATABASE db_name; #db_name为表名

3. Using the Database

Use db_name;

4. Deleting a database

DROP DATABASE db_name;

Two. Create a table

1. Create a table

CREATE TABLE table_name (    ID  TINYINT UNSIGNED not NULL auto_increment,    Char () not       null    ,int           is not null,    PRIMARY KEY (ID  )     #设置主键) ENGINE=innodb;

2. Copying a table

CREATE TABLE tb_name2 SELECT * from Tb_name;

3. Create a temporary table

# (This is the same as creating a normal table)

4. View the tables available in the database

SHOW TABLES;

5. View the structure of the table

DESCRIBE Tb_name;

6. Delete a table

DROP TABLE Tb_name;

7. Table renaming

RENAME TABLE name_old to Name_new;

Three. Modify the table

ADD COLUMN address varchar (theDROP Change score score SMALLINT (4) is not NULL;

Four. Inserting data

1. Inserting data

INSERT into tb_name (ID, name,score) VALUES (null,' Zhang San ',+), (null,'  Zhang Si ',178), (NULL,' Zhang five ',134);

2. Inserting the retrieved data

INSERT into Tb_name (name,score) SELECT name,score from Tb_name2;

Five. Updating data

UPDATE tb_name SET score=189id=2; UPDATE tablename SET columnName=newvalue [WHERE condition]

Three. Filtering with wildcards

' jet% '    #% matches any character that occurs any number of times
' _ Jet ';   #_ match one character

MySQL Database common operation collation

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.