【day1】MySQL資料的增刪改查

來源:互聯網
上載者:User

標籤:har   esc   sel   databases   改變   use   where   約束   color   

  對資料的操作:增查改刪

  資料操作的層級:庫資料的操作,表資料的操作,表段資料的操作。

 

  庫層級的操作:

  

1 增:建立資料庫 create database db1;2       切換資料庫 use db1;3 查:查詢資料庫 show databases;4 改:改資料庫名 rename database oldname to newname;5 刪:刪除資料庫 drop database db1;6    

  表層級的操作:

增:create table t1(id int(10),name char(10));查:show tables;      desc t1; 查看t1詳情改表名:alter table oldname rename newname;刪:drop table t1;改變表的結構:
  alter table t1 add age int; 在t1中添加欄位age

  表欄位層級的操作:

設定自增ID(約束條件):        create table t1(id int primary key auto_increment,name char(10));    增:        insert into db1.t1 values<1,‘egon1‘>;        insert int db1.t1 values<2,‘egon2‘><3,‘egon3‘>;改:update t1 set name=‘sb‘ where id=4;將id為4的name值改為sb      update t1 set name = ‘‘ where id=4;將id為4的name值改為空白刪:刪除資料:        delete from t1 where id=4;查:  select name from t1 where id>4;查詢t1中id大於4的所有name值

 

【day1】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.