sql语句

-- 创建数据库

create  database  数据库名    default  charset =utf8;

 

-- 创建表

create table  表名  ( id    int,name  char(20));

create table  表名  (id int   null/not null,name  char(20) )  engine=innodb  default charset=utf8;

create  table 表名     (id int null,    name char(20) not null,    age int not null    auto_increment primary key)  engine=innodb default charset=utf8;

create  table  表名  (num  decimal(10,5))          decimal类型指小数点前允许有十位数,小数点后允许有五位数,decimal,float,double都属于小数类型

 

-- 清空表

delete  from  表名;                             自增id会继续往后走

truncate  table  表名;                         自增id将从1开始

delete  from table  where  id <6;

 

--删除表

drop table 表名;

 

-- 查询表

select * from 表名;

 

-- 修改表

updata  表名  set  age =18;

update 表名   set  age=18  where  age=17;

 

-- 向表内插入数据

insert  into  表名(id,name) values(1,'alex');

 

-- 查看数据库

show databases;

 

posted @ 2020-06-03 18:05  misherry  阅读(152)  评论(0编辑  收藏  举报