Mysql数据库基础操作

//连接数据库;
mysql -uroot -hlocalhost -p
//修改数据库密码;
use mysql;
update user set password=password("123456") where user="root";
FLUSH PRIVILEGES; 
//数据库增删改查
crud(增加create,查询read,修改update,删除delete);
//创建表;
create table carmack_on(
	id int auto_increment primary key,
	name varchar(30) not null,
	user varchar(30) not null,
	password varchar(40) not null)character set gbk collate gbk_chinese_ci;
//修改列名字;
alter table carmack_on change name namer int;
//增加列;
alter table carmack_on add ok varchar(30);
//删除列;
alter table carmack_on drop ok;
//修改列属性;
alter table goods modify id varchar(40);
//修改表名字;
rename table carmack_on to carmack_one;
//修改库名字(数据表转到新库);
rename table carmack_on to test.carmack_on;
//增数据
insert into carmack_one (name,user) values ("王凯","root");//如果要增加所有字段值可省略字段名顺序不乱
//删数据
delete from carmack_one where 1//删除一定要条件比较严格不可逆;
//改数据
update carmack_one set user="gaihao" where 1;
//查数据
select *{列名} from carmack_one where 1{条件 1位默认}//where fenshu>=90;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值