1. 程式人生 > >20181022mysql操作一:建立庫,表的增刪改查,資料的增刪改

20181022mysql操作一:建立庫,表的增刪改查,資料的增刪改

1、建立資料庫

create database python charset=utf8;

2、使用資料庫

use python;

3、建立表結構

create table student(

    id int primary key auto_increment not null unique,

    name varchar(20) not null,

    age int default 18

);

4、修改表結構-新增欄位

alter table student add height decimal(5,2);

5、修改表結構-修改欄位屬性

alter table student modify height decimal(6,2);

6、修改表結構-修改欄位名

alter table student change height high decimal(6,2);

7、查看錶結構

desc student;

8、表中插入一條語句1

insert into student values(0,'小王',18,1.82);

9、表中插入一條語句2

insert into student (name,age) values('劉德華',18);

10、表中修改一條語句

update student set age=19 where id=1;

11、查詢表中所有資料

select * from student;

12、刪除表中一個條目

delete from student where id=1;