mysql資料庫之基本增刪改查

來源:互聯網
上載者:User

標籤:log   lex   database   value   creat   結構   bsp   prim   des   

#1 操作檔案夾(庫)    增        create database db1 charset utf8;    查        show databases;        show create database db1;    改        alter database db1 charset gbk;    刪        drop database db1;#2 操作檔案(表)    切換到檔案夾下:use db1    增        create table t1(id int,name char(10))engine=innodb;        create table t2(id int,name char(10))engine=innodb default charset utf8;    查        show tables;        show create table t1;        desc t1;#查看錶結構    改        alter table t1 add age int;        alter table t1 modify name char(12);    刪        drop table t1;#3 操作檔案的一行行內容(記錄)    增        insert into db1.t1 values(1,‘egon1‘),(2,‘egon2‘),(3,‘egon3‘);        insert into db1.t1(name) values(‘egon1‘),(‘egon2‘),(‘egon3‘);    查        select * from t1;        select name from t1;        select name,id from t1;    改        update t1 set name=‘SB‘ where id=4;        update t1 set name=‘SB‘ where name=‘alex‘;    刪        delete from t1 where id=4;        #對於清空表記錄有兩種方式,但是推薦後者        delete from t1;        truncate t1; #當資料量比較大的情況下,使用這種方式,刪除速度快    #自增id    create table t5(id int primary key auto_increment,name char(10));    create table t4(id int not null unique,name char(10));insert into t5(name) values(‘egon5‘),(‘egon6‘),(‘egon7‘),(‘egon8‘),(‘egon9‘),(‘egon10‘),(‘egon11‘),(‘egon12‘),(‘egon13‘);

 

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.