簡單回顧一下MySQL命令列操作

來源:互聯網
上載者:User

標籤:varchar   uniq   回顧   weight   張無忌   add   png   code   建立資料庫   

再通過cmd 命令進入資料庫之後就要手動的對資料庫一些操作

建立資料庫加上分號

mysql>create database myfirstdatabase;

查看所建立的資料庫加上s和分號

mysql>show databases;

選擇要使用的資料庫加分號

mysql>use myfirstdatabase;

建立資料庫表加分號,並且加上字元格式設定utf8

mysql>create table table_name(        >code varchar(20),        >name varchar(20),        >age int);

查看資料庫中的表加s和分號

mysql>show tables;

 資料庫操作 select 、insert、update、delete

select code,name,age from table_name;insert into table_name(‘0001‘,‘張無忌‘,23);update table_name set name=‘張翠山‘ where code=‘0001‘;delete from table_name where code=‘0001‘;

delete 操作還是和MS-SQL有一點差距的。

查看錶設計

mysql>desc table_name;

添加一個表的欄位加分號;

mysql>alter table table_name add address varchar(20);

修改表中某一欄位

mysql>alter table table_name change address address varchar(50);

刪除表中的某一列

mysql>alter table table_name drop address;

表中某一欄位設為主鍵

mysql>alter table table_name add primary key (code);

表中某一欄位加入普通索引、唯一索引關鍵字 unique、全文索引fulltext、多列索引

mysql>alter  table table_name add index index_name(codel);
mysql>alter table table_name add index index_name(code,name);

 

簡單回顧一下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.