mysql数据库基本操作(一)

创建数据库:create database test;
查看数据库:show databases;
使用数据库:use test;
这里写图片描述
查看当前使用的数据库:select database();
这里写图片描述
删除数据库:drop database test;(慎用!!!!!!!!!!!!!!)

创建表:create table people(id int primary key auto_increment,name varchar(20) not null,age int(8) not null,brithday datetime);
这里写图片描述

查看表:show tables;
查看表结构:desc people;
这里写图片描述

向表中插入一列:alter table people add handsome bool;
查看表结构:desc people;
这里写图片描述

修改表中字段属性:alter table people modify age int(4);
查看表结构:desc people;
这里写图片描述

删除列:alter table people drop column handsome;

修改表名:rename table people to information;
查看表:show tables;
这里写图片描述

复制表:create table copy_information select * from information;
查看表:show tables;
这里写图片描述

向表中插入数据:insert into information values(1,’张三’,23,’1993-04-12’,True);
查看表中内容:select * from information;
这里写图片描述

向表中添加多条数据,查看表中内容:select * from information;
这里写图片描述

删除表中数据:delete from information where name = ‘李四’;
查看表中内容:select * from information;
这里写图片描述

修改表中数据内容:update information set name=’叶良成’ where name=’李三’;
查看表中内容:select * from information;
这里写图片描述

创建表时候添加默认注释
CREATE TABLE test(
id int primary key auto_increment comment ‘主键自增’,
name varchar(200) comment ‘姓名’,
) comment=’表注释’;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值