一、建立資料庫
1.語法
注意:建立資料庫時,如果沒有指定字符集和校驗規則時,系統使用預設字符集:utf8,校驗規則是:utf8_ general_ cicreate database [if not exists] db_name [create_specification [, create_specification]
...]
create_specification:
[default] character set charset_name
[default] collate collation_name
建立案例:建立乙個資料庫名為test,字符集為utf8,校驗規則為utf8_ general_ ci 的資料庫
create database test charset=utf8 collate utf8_general_ci;
2.檢視
(1)檢視資料庫
show databases;
(2)檢視資料庫字符集
(3)檢視資料庫校驗規則-- 檢視資料庫支援的字符集
show charset;
-- 檢視資料庫預設字符集
show variables like 'character_set_database';
注意:校驗規則為 utf8_ general_ ci 不區分大小寫,校驗規則 utf8_ bin 區分大小寫-- 檢視資料庫支援的字符集校驗規則
show collation;
-- 檢視系統默校驗規則
show variables like 'collation_database';
(4)檢視資料庫建立語句
三、修改資料庫-- 語法:show create database 資料庫名;
show create database test;
1.修改字符集
alter database test charset=gbk;
2.刪除資料庫
3.備份資料庫-- drop database [if exists] db_ name;
drop database test;
注意:輸入此命令要退出資料庫,截圖如下-- mysqldump -u root -p 密碼 -b 資料庫名 > 資料庫備份儲存的檔案路徑
mysqldump -u root -p -b test > ./test
4.恢復備份的資料庫
注意:如果沒有加 -b 選項,則需要重新建立資料庫-- 資料庫內:source 路徑/資料庫名
source ./test.sql
-- 資料庫外:mysqldump -u root -p密碼 -b 資料庫名1 資料庫名2 ... > 資料庫存放路徑
資料庫(庫操作)
information schema 虛擬庫,不占用磁碟空間,儲存的是資料庫啟動後的一些引數,如使用者表資訊 列資訊 許可權資訊 字元資訊等 performance schema mysql 5.5開始新增乙個資料庫 主要用於收集資料庫伺服器效能引數,記錄處理查詢請求時發生的各種事件 鎖等現象 my...
資料庫 資料庫基本操作
操作練習 修改表結構 表資料的操作 實現 1 建立表 create table student stu no char 12 not null primary key,stu name varchar 20 not null gender tinyint 1 default1,age tinyint...
資料庫操作
第乙個問題 通常用datareader對像 sqlcommand comm new sqlcommand select count from login where name textbox1.text and password textbox2.text,conn datareader dr co...