MySQL 基礎(DDL)

來源:互聯網
上載者:User

標籤:

SQL分類
        SQL語句主要可以劃分為一下3個類別
     DDL:資料定義語言 (Data Definition Language),定義資料區段、資料庫、資料表等     DML :資料操縱語句,用於添加、刪除、更新和查詢資料庫記錄     DCL :資料控制語句,用於控制不同資料區段直接的許可和存取層級的語句

       準備工作,先啟動MySQL服務 net start mysql ,進入mysql, mysql -u root -p  (-u 後面跟資料庫使用者, -p 表示需要輸入密碼)

     
1. DDL語句

        對資料庫內部的對象進行建立、刪除、修改等操作的語言。

    1.1 建立資料庫                create  database  ----;        
    

            建立好資料庫之後,查看資料庫  show databases;

               

            選擇要操作的資料庫   use ---    
       查看該資料庫中的表  show tables;

                               1.2 刪除資料庫

       drop database ----;

                   
    1.3 建立表

       create table ---  (name1 type 約束條件,name2 type 約束條件 ......);
       查看剛剛建立的表,看是否符合要求   desc --;

           
    1.4 刪除表

       drop table ----;

       
    1.5 修改表

         修改表中某項的資料類型   alter table --- modify  ---;

           

             增加新欄位   alter  table ---  add colum ----;

         


         刪除欄位       alter  table ---  drop colum ---;
         修改欄位名   alter  table ---  change ---;

             
      

MySQL 基礎(DDL)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.