命令列操作MySQL的一些簡單命令

2021-07-09 15:51:05 字數 2229 閱讀 7429

啟動mysql                       net start mysql    

停止mysql                       net stop mysql  

進入mysql安裝目錄        c:\wamp\bin\mysql\mysql5.6.17\bin\ 

進入mysql                        mysql.exe -h localhost -u root -p 

退出mysql                       exit; 

檢視已建立的資料庫        show databases; 

建立資料庫                        create database fly_test character set gbk; 

指定使用的資料庫            use fly_test; 

建立表                                create table students(id int not null auto_increment,name varchar(12),age int,*** varchar(4),primary key (id) );

檢視表                                show tables; 

檢視表的詳細資訊            describe students; 

插入資料                            insert into students values(  "白鴿", "男", 20, "18888888888" ); 

insert into students(name, ***, age)values("龍顏", "男", 10);

查詢                                    select name, age from students;

select * from students;

條件查詢                            select * from students where age > 12; 

select * from students where name like "%白";

select * from students where id < 5 and age > 2;

排序                                    select * from students order by age [desc];

更新                                    update students set tel = default where id = 1; 

update students set age = age + 1;

update students set name = "baige", *** = "nan" where age = 21;

刪除                                    delete from students where id =3; 

刪空表                                delete from students; 

新增列                                alter table students add address char(60); 

alter table students add birthday date after age;

alter table students change tel telphone char(13) default "-";

alter table students change name name char(16) not null;

刪除列                                alter table students drop birthday;

重新命名表                            alter table students rename workmates; 

刪除整張表                        drop table 表名;

刪除資料庫                        drop database 資料庫名; 

mysql 的一些命令列

一次性修改表中所有欄位的字符集語句 alter table 表名 convert to character set utf8 修改表的編碼方式 alter table test default character set utf8 該命令用於將表test的編碼方式改為utf8 修改欄位的編碼方式 a...

一些常用的命令列操作

作為乙個計算機專業的學生,掌握一些常用的dos命令,十分必要,具體如下 換碟符,例如轉到d盤 d 羅列出當前目錄下的檔案以及資料夾 dir 建立資料夾 md 資料夾名稱 進入指定目錄 cd 資料夾名稱,或者cd 碟符 資料夾名稱 退回到上一級目錄 cd 退回到根目錄 碟符 cd 或者 cd 建立乙個...

命令列設定raid MegaCli一些簡單用法

檢視raid級別 megacli ldinfo lall aall 檢視raid卡資訊 megacli adpallinfo aall 檢視硬碟資訊 megacli pdlist aall 檢視電池資訊 megacli adpbbucmd aall 檢視raid卡日誌 megacli fwterml...