登錄:[mysql@localhost~]$ sudo bin/mysql --port=3306 -u root -p -S /tmp/mysql.sock
install Doct include: windows --------------------------------------- 目錄 目錄內(nèi)容 ----------------------------------------- bin 客戶端程序和mysql服務(wù)器 data 日志文件 數(shù)據(jù)庫
docs 文檔
examples 示例程序和腳本
nclude 包含頭文件
lib 庫
scripts 實用工具腳本
share 錯誤消息文件
==========================
安裝后將會在以下系統(tǒng)目錄產(chǎn)生文件 linux --------------------------------------- /usr/bin 客戶端程序和腳本 /usr/sbin mysql服務(wù)器
/var/lib/mysql 日志文件 數(shù)據(jù)庫
/usr/share/doc/packages 文檔
/usr/incude/mysql 包含頭文件
/usr/lib/mysql 庫
/usr/share/mysql 錯誤消息和字符文件
/usr/share/sql-bench 基準程序 -------------------------------- =======================操作==============================
1. 創(chuàng)建/刪除數(shù)據(jù)庫:create/drop database xxx;
2. 創(chuàng)建/刪除表: create/drop table xxx [valuse ()]; 3. 添加索引等: create index on xxx (yyy); 4. 復制表: create table yyy select [*,y,z ]from xxx [where gggg]; 此時表的結(jié)構(gòu)類似 建立空表 在 where 中設(shè)置一個不存在的關(guān)系 create table like xxx; 5. 修改表: 添加新字段 alter table xxx add xyz hfbi ; 修改已存在的字段的名字和類型: alter table change xxx yyy fdhjj; 刪除字段: alter table xxx drop yhn; 重命名: alter table xxx rename to yyy; rename table xxx to yyy; 6. 使用數(shù)據(jù): 插入記錄:insert into xxx values (); 更新記錄:update xxx set hgk=gjhau [where nuhgkji]; 刪除記錄:delect from xxx where jkhaurh; 當省略 where 時刪除所有記錄 內(nèi)建函數(shù):select sum() avg() now() from xxx [where jhak]; 好像不能和字段在一塊查詢? 別名 as 限制 limit 排序 orer by [asc desc] 分組 group by 使用變量: select @dfkb:=某操作結(jié)果 使用: select @dfkb; select fhu from xxx where bflb=@dfkb; 復制記錄:insert into xxx [()] select jg,gh from yyy [where jha]; 批量數(shù)據(jù):load data local infile '/home/lvshang/....' into table xxx fields terminated by ',' lines terminated by '\n\; 導出記錄:select gi,jghe from xxx [where fhfnk ] into outfile '/home/lvshang/yyyy' fields terminsted by ',' enclosed by '"' lines terminated by '\t\n'; 1.修改表的相關(guān)內(nèi)容的知識
1.1
alter table biao1 add clomname xxx; 追加新的字段 1.2 alter table biao1 drop clomname; 刪除原有的字段 1.3 alter table biao1 change clomname clomname_new xxx ; 改編字段的相關(guān)內(nèi)容 1.4 alter tbale biao1 modify clomname xxxx; 只是修改字段的類型等內(nèi)容,不改變字段的名字 1.5 alter table biao1 rename to name_new; rename table biao1 to name_new; 均為重命名表明 1.6 alter table biao1 alter clomname set default xx/drop default 為一個字段設(shè)置或刪除默認值xx (數(shù)字),不常用 1.7 alter ignore table biao1 change clomname xxx unique; 將表的clomname 字段設(shè)置為不允許重復的出現(xiàn)。注意前面的 IGNORE 1.8 alter table biao1 type= xxx; 將表的類型改為 xxx . 1.9 alter table biao1 add fulltext index xxx; alter table biao1 drop index xxx; 增加/刪除索引 2. 批量添加本地文件: load data local infile '/usr/lvshang/biaox' into table biaoy fields terminated by ',' lines terminated by '\n';
|
|
來自: shangat > 《Linux 文章》