MySQL Learning notes

Source: Internet
Author: User

Database P3306
CREATE DATABASE [if not EXISTS] db_name [characterset GBK];
Use database;//Jump database
show databases;
Alert Database db_name Character Set utf8;//modified
drop databases [if not EXISTS] dbname;//Most useful
Show Create Databses dbname;

Table
CREATE TABLE [i n e] tbname (
ID smallint unsigned PrimaryKey auto_increment,
name varchar (TEN) is not NULL,

);
NOT NULL non-null auto_increment self-increment primary key unique key uniqueness constraint
default ' '

Describe[desc] Stu;
show tables;
Show CREATE table tbname;

Alert Table users1 add age tinyint unsigned not null default ten;
Alert Table Tbname Add colname coldef,...//Add multiple columns
Alert table tbname Add password varchar (+) NOT null after username//added after username
Alert Table Tbname add truename varchar (TEN) NOT null first//first
Alert table tbname drop password,drop age;//Delete multiple columns

int tinyint decimal (legth,dec) text char varchar//data type

Increase
INSERT INTO Tbname (collist) VALUES (val)
Delete
Delete from tbname where name=xx;
more
Update tbname set col= ' where xx=xx;
Check
Select ColName from Tbname where ... order by colname ASC default |desc descending limit 3,2

and and and OR or not
min Max sum avg count ()

MySQL Learning notes

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.