Mysql数据库基础操作

来源:互联网 发布:淘宝宝贝限时打折 编辑:程序博客网 时间:2024/06/01 08:30
//连接数据库;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
原创粉丝点击