複習篇--mysql 基礎語句

來源:互聯網
上載者:User

標籤:mysql

1.資料庫(此處"pikachu“為資料庫名稱)

      SHOW  DATABASES;                      ##查看資料庫

      USE  pikachu;                                ##切換到資料庫
      CREATE  DATABASE  pikachu;        #建立資料庫

      DROP  DATABASE  pikachu;           #刪除資料庫

 

  2.表(此處"student"為表名稱)

       SHOW TABLES;                             #查看錶
       CREATE  TABLE  student (name VARCHAR(20), sex CHAR(1));     ##建立表

       DROP  TABLE   student ;                 ##從資料庫中刪除表     

       DESCRIBE   student;                       ##查看錶結構
       INSERT   INTO    student   VALUES (‘lmy‘,‘F‘);                      ## 向表中添加資訊  

        DELETE     FROM    student   WHERE   attribute = value;     ##從表中刪除資訊
       SELECT   *    FROM   student;          ##查看錶中所有資訊            
       UPDATE    student  SET   attribute=value2 WHERE attribute > =value1;   ##修改表中資訊,將表中的value1改為value2 

       ALTER   TABLE  student   add  age varchar(4);    ##向表中添加"age"欄位

       ALTER   TABLE   student  DROP  age;                  ##從表中刪除欄位


  3.查詢

        SELECT  *  FROM  pikachu.student;       ##查詢pikachu資料庫下的student表

        SELECT   name  FROM   student    WHERE    age=‘20‘  and  sex=‘M‘;   ##查詢student表中年齡為20,性別男的人的姓名

  4.重新整理資料庫資訊

       FLUSH  PRIVILEGES;          

  5.mysql root使用者密碼忘記解決辦法




       

本文出自 “11849650” 部落格,謝絕轉載!

複習篇--mysql 基礎語句

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.