啟動:net start mysql;
進入:mysql -u root -p/mysql -h localhost -u root -p databaseName;
列出數據庫:show databases;
選擇數據庫:use databaseName;
列出表格:show tables;
顯示表格列的屬性:show columns from tableName;
建立數據庫:source fileName.txt;
匹配字符:可以用通配符_代表任何一個字符,%代表任何字符串;
增加一個字段:alter table tabelName add column fieldName dateType;
增加多個字段:alter table tabelName add column fieldName1 dateType,add columns fieldName2 dateType;
多行命令輸入:注意不能將單詞斷開;當插入或更改數據時,不能將字段的字符串展開到多行里,否則硬回車將被儲存到數據中;
增加一個管理員帳戶:grant all on *.* to user@localhost identified by "password";
每條語句輸入完畢后要在末尾填加分號';',或者填加'/g'也可以;
查詢時間:select now();
查詢當前用戶:select user();
查詢數據庫版本:select version();
查詢當前使用的數據庫:select database();
1、刪除student_course數據庫中的students數據表:
2、備份數據庫:(將數據庫test備份)
3、創建臨時表:(建立臨時表zengchao)
4、創建表是先判斷表是否存在
5、從已經有的表中復制表的結構
6、復制表
7、對表重新命名
8、修改列的類型
9、創建索引
10、刪除索引
新聞熱點
疑難解答