码迷,mamicode.com
首页 > 数据库 > 详细

MySQL学习笔记

时间:2016-12-24 02:16:34      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:mysq   insert   约束   default   tables   arc   sel   mic   tab   

数据库 P3306
create database [if not exists] db_name [characterset gbk];
use database;//跳转数据库
show databases;
alert database db_name character set utf8;//修改
drop databases [ if not exists] dbname ;//最有用的
show create databses dbname;


create table [i n e] tbname(
id smallint unsigned primarykey auto_increment,
name varchar(10) not null,

);
not null非空  auto_increment自增 primary key unique key 唯一约束
default ‘ ‘

describe[desc] stu; 
show tables;
show create table tbname;

alert table users1 add age tinyint unsigned not null default 10;
alert table tbname add colname coldef,...//添加多列
alert table tbname add password varchar(32) not null after username//在username后添加
alert table tbname add truename varchar(10) not null first//最前
alert table tbname drop password,drop age;//删除多列

int tinyint decimal(legth,dec) text char varchar //数据类型


insert into tbname(collist) values(val)

delete from tbname where name=xx;

update tbname set col=‘‘ where xx=xx;
查 
select colname from tbname where ...... order by colname asc默认|desc降序 limit 3,2

and并且 or或者 not 
min max sum avg count() 

MySQL学习笔记

标签:mysq   insert   约束   default   tables   arc   sel   mic   tab   

原文地址:http://www.cnblogs.com/crosys/p/6216394.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!