新聞中心
以下的文章主要向大家描述的是MySQL基本操作,MySQL在實(shí)際操作中是經(jīng)常被用到的,所以對(duì)MySQL的基本內(nèi)容的了解也是一件很重要的事項(xiàng),以下的文章就是對(duì)MySQL基本操作的詳細(xì)描述。

創(chuàng)新互聯(lián)公司服務(wù)項(xiàng)目包括子長(zhǎng)網(wǎng)站建設(shè)、子長(zhǎng)網(wǎng)站制作、子長(zhǎng)網(wǎng)頁(yè)制作以及子長(zhǎng)網(wǎng)絡(luò)營(yíng)銷策劃等。多年來(lái),我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,子長(zhǎng)網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到子長(zhǎng)省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
登陸數(shù)據(jù)庫(kù)
D:\phpStudy\MySQL\bin>MySQL -uroot -proot
查看數(shù)據(jù)庫(kù)
MySQL> show databases;
選擇數(shù)據(jù)庫(kù)
MySQL> use bugfree;
設(shè)置字符集
MySQL> set names 'gbk';
查詢數(shù)據(jù)庫(kù)中的表
MySQL> show tables;
MySQL基本操作創(chuàng)建表
MySQL> create table test(
-> tid int(10) not null,
-> tname varchar(100) not null,
-> tdate datetime not null default '0000-00-00',
-> primary key (tid));
查看表結(jié)構(gòu)
MySQL> desc test;
添加列
MySQL> alter table test add(tage int(3));
修改原表結(jié)構(gòu)
MySQL> alter table test modify tage int(5) not null;
修改列的默認(rèn)值
MySQL> alter table test alter tage set default '0';
去掉列的默認(rèn)值
MySQL> alter table test alter tage drop default;
刪除列
MySQL> alter table test drop column tage;
插入數(shù)據(jù)
MySQL> insert into test(tid,tname,tdate) value(1,'yangjuqi','2008-03-21');
查詢數(shù)據(jù)
MySQL> select * from test;
模糊查詢
MySQL> select * from test where tname like '%楊%';
修改數(shù)據(jù)
MySQL> update test set tname='張三' where tid='2';
MySQL基本操作刪除數(shù)據(jù)
MySQL> delete from test where tid='2';
刪除表
MySQL> drop table test;
重命名表
MySQL> alter table test rename testbak;
分頁(yè)查詢(limit 起始行,取多少行)
MySQL> select * from testbak limit 2,1;
刷新數(shù)據(jù)庫(kù)
MySQL> flush privileges;
顯示數(shù)據(jù)庫(kù)版本
MySQL> select version();
顯示當(dāng)前時(shí)間
MySQL> select current_date;
修改用戶密碼
D:\phpStudy\MySQL\bin>MySQLadmin -uroot -proot password yangjuqi
將查詢出的數(shù)據(jù)寫(xiě)入文件
MySQL> select * from testbak into outfile "d:/test.txt" fields terminated by ",";
查看數(shù)據(jù)庫(kù)狀態(tài)
MySQL> status;
MySQL基本操作查看所有編碼
MySQL> show variables like 'character_set_%';
導(dǎo)入sql文件命令
MySQL>source d:/MySQL.sql;
分享標(biāo)題:MySQL基本操作,新手入門(mén)寶典
本文鏈接:http://www.5511xx.com/article/cdscjds.html


咨詢
建站咨詢
