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;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章