数据库的操作

一、基本操作
1、创建数据库
链接数据库

 mysql -uroot -p+(密码)

退出

quit/exit

创建

create database AB_name charset=utf8;

2、选择数据库

进入数据库 use AB_name ;
查看当前所选的数据库: select database();

3、创建表

创建一个顾客表
create table customer(id int primary key auto_increment not null,
            name varchar(10) not null,
            password varchar(10) not null,
            gender enum('boy','girl','secret'),
            active int default 0);

4、查看数据库里的表

show tables;

5、查看表的结构

desc customer(表名)

6、删库操作

drop database AB_name;

7、增加字段

alter table customer add email varchar(20) not null;

8、修改字段

alter table customer change name user_name varchar(20) not null;

9、删除字段

alter table customer drop email;

10、删除表

 drop table customer
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值