MySQL学习笔记

时间:2024-11-10 17:03:26

数据库 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()