1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      mysql知識點簡單總結(jié)

      1.操作數(shù)據(jù)庫語句

      創(chuàng)新互聯(lián)擁有十余年成都網(wǎng)站建設(shè)工作經(jīng)驗,為各大企業(yè)提供做網(wǎng)站、成都網(wǎng)站制作服務(wù),對于網(wǎng)頁設(shè)計、PC網(wǎng)站建設(shè)(電腦版網(wǎng)站建設(shè))、成都app軟件開發(fā)公司、wap網(wǎng)站建設(shè)(手機版網(wǎng)站建設(shè))、程序開發(fā)、網(wǎng)站優(yōu)化(SEO優(yōu)化)、微網(wǎng)站、主機域名等,憑借多年來在互聯(lián)網(wǎng)的打拼,我們在互聯(lián)網(wǎng)網(wǎng)站建設(shè)行業(yè)積累了很多網(wǎng)站制作、網(wǎng)站設(shè)計、網(wǎng)絡(luò)營銷經(jīng)驗,集策劃、開發(fā)、設(shè)計、營銷、管理等網(wǎng)站化運作于一體,具備承接各種規(guī)模類型的網(wǎng)站建設(shè)項目的能力。

        1.1 顯示所有的數(shù)據(jù):show databases;

        1.2 創(chuàng)建數(shù)據(jù)庫:create database databasename;

        1.3 刪除數(shù)據(jù)庫:create database databasename;

        1.4備份數(shù)據(jù)庫:MySQLdump –uroot –p1234 databasename>本地保存的路徑

        1.5恢復(fù)數(shù)據(jù)庫:mysql –uroot –p1234 databasename<本地保存的路徑

        1.6查看所在數(shù)據(jù)庫:select database();

      2.操作數(shù)據(jù)表語句

        2.0 查詢所有的表:show tables;

        2.1 創(chuàng)建表:create table tablename(

                                  字段1名稱  字段1類型,

                               字段n名稱  字段n類型(最后一項,不加逗號)

      );

        2.2 修改表:

      2.2.1 添加字段: alter table 表名 add 字段名 字段類型;

      2.2.2 修改表名:  alter table 表名 rename to 新表名;

      2.2.3 修改字段類型: alter table表名modify 字段名 字段新類型;

      2.2.4 修改字段:  alter table表名change 字段名 新字段名 新類型;

      2.2.5 刪除字段: alter table 表名 drop 字段名;

      2.2.6 刪除表: drop table 表名;

      2.2.7 設(shè)置主鍵:

            create table 表名(

                         字段1名稱 字段1類型 primary key,

                字段2名稱 字段類型

      );

       

      create table 表名(

             字段1名稱 字段1類型 primary key,

             字段2名稱 字段2類型,

             primary key(字段1名稱)

      );

       

      create table 表名(

             字段1名稱 字段1類型,

          字段2名稱字段2類型

      );

      alter table 表名 add 字段名 primary key;

           2.2.8設(shè)置自增長:

                    create table 表名(

                                  字段1名稱 字段1類型 primary key auto_increment,

                                  字段2名稱 字段2類型

      );

             //注意:自增長是對主鍵且數(shù)據(jù)類型為數(shù)值型的字段而言的

             2.2.9 設(shè)置約束條件:unique(唯一性),not null(非空),default(默認)

        2.3 查詢表:

           2.3.1 查詢所有數(shù)據(jù): select * from 表名

           2.3.2 查詢符合字段類型(數(shù)值)的數(shù)據(jù): select * from 表名 where 字段名=id;

           2.3.3 查詢符合字段類型(字符串)的數(shù)據(jù):select * from 表名 where 字段名=‘str’;

           2.3.4 查詢含有某字符的數(shù)據(jù):select * from 表名 where 字段名 like ‘%r%’;

           2.3.5 查詢不含某字符的數(shù)據(jù):select * from 表名 where 字段名 not like ‘%r%’;

           2.3.6 查詢同時滿足多個條件的數(shù)據(jù):

               Select * from 表名 where id in(條件1,條件2);

               Select * from 表名 where 條件1 and 條件2;

           2.3.7 查詢滿足多個條件之一的數(shù)據(jù):

               Select * from 表名 where 條件1 or 條件2;

       

      truncate and delete的區(qū)別:

      (1)truncate既刪除表內(nèi)數(shù)據(jù),也刪除表的結(jié)構(gòu),刪除表結(jié)構(gòu)后,會重建表的結(jié)構(gòu)

      (2)delete只刪除表內(nèi)的數(shù)據(jù)

      having與 where的區(qū)別:

      (1)having后面跟函數(shù),having是對結(jié)果的篩選

      (2)where后面跟字段

      關(guān)鍵字的書寫順序:

             select,from,where,group by,having,order by

      關(guān)鍵字的執(zhí)行順序:

             【from】 【where,group by,having 條件】 【select】 【order by】

       

      內(nèi)連接:

             inner join on(內(nèi)連接),可以多表進行內(nèi)連接

      demo:

      //內(nèi)連接示例

      select s.sname, c.cname from sinfor s inner join scinfor sc on s.sid=sc.sid

                                          inner join cinfor c on sc.cid=c.cid;

      結(jié)果:           +-------+---------+

          | sname  | cname   |

          +-------+---------+

          | s1       | java      |

          | s2       | java      |

          | s1       | android  |

          | s3       | php      |

          +------+--------+

       

      外連接:

             (1)left join on(左外連接),以左邊的表為基表

             demo:

      select s.sname, c.cname from sinfor s left join scinfor sc on s.sid=sc.sid

                                          left join cinfor c on sc.cid=c.cid;

      輸出結(jié)果:

                            +-------+---------+

      | sname | cname   |

      +-------+---------+

      | s1       | java        |

      | s1       | android  |

      | s2       | java       |

      | s3       | php       |

      | s5       | NULL     |

      +-------+---------+

       

      (2)right join on(右外連接),以右邊的表為基表

      demo:

      select s.sname, c.cname from sinfor s right join scinfor sc on s.sid=sc.sid

                                              right join cinfor c on sc.cid=c.cid;

      輸出結(jié)果:

                      +-------+---------+

      | sname | cname   |

      +-------+---------+

      | s1        | java       |

      | s2        | java       |

      | s1        | android  |

      | s3        | php       |

      | NULL   | C#         |

      +-------+---------+

      附sql語句:
      表1 sinfor (學生表):

             create table sinfor(

                    sid int primary key,

                    sname varchar(32)

      );

             表2 scinfor(選課表):

             create table scinfor(

                    sid int,

                    cid int,

                    primary key(sid,cid),

                    foreign key(sid) references sinfor(sid),

                    foreign key(cid) references cinfor(cid)

      );

             表3 cinfor (課程表):

                    create table cinfor(

             cid int primary key,

             cname varchar(32)

      );

      insert into sinfor values(1, 's1');

      insert into sinfor values(2,'s2');

      insert into sinfor values(3,'s3');

      insert into sinfor values(4,'s5');

      insert into cinfor values(1,'java');

      insert into cinfor values(2,'android');

      insert into cinfor values(3,'php');

      insert into cinfor values(4,'C#');

      insert into scinfor values(1,2);

      insert into scinfor values(2,1);

      insert into scinfor values(3,3);

      insert into scinfor values(1,1);


      文章標題:mysql知識點簡單總結(jié)
      URL鏈接:http://www.ef60e0e.cn/article/jhiech.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        吉隆县| 河间市| 太谷县| 宣武区| 麻城市| 西平县| 朝阳县| 普兰店市| 漯河市| 平谷区| 耒阳市| 通道| 微博| 镇坪县| 湾仔区| 宁阳县| 札达县| 乌拉特后旗| 昌宁县| 棋牌| 江陵县| 离岛区| 上高县| 阿尔山市| 静海县| 张家川| 仁怀市| 古交市| 盐亭县| 湖口县| 青岛市| 平顶山市| 莒南县| 寿光市| 彰化县| 宿州市| 河南省| 永和县| 婺源县| 若羌县| 扬中市|