Mysql簡單操作

來源:互聯網
上載者:User

標籤:

 

//Mysql版本:5.7.13

 

1.以管理員身份運行命令提示字元,轉到mysql的安裝位置
2.啟動mysql服務:net start mysql
3.root身份登入:mysql -uroot -p 斷行符號鍵


4.列出所有資料庫:show databases;
5.建立一個資料庫:create databases Database_Name;
6.判斷是否存在再建立資料庫:create databases if not exists Database_Name;
7.刪除資料庫:drop database Database_Name;
8.選擇一個資料庫:use Database_Name;


9.列出選中資料庫中的所有資料表:show tables;
10.展示資料表的列(column)詳情:show columns from Table_Name;或者:describe Table_Name;
11.選中展示資料表:select * from Table_Name;
12.帶條件展示資料表:select * from Table_Name where id>=2;
13.建立資料表:create table Table_Name(col_01_Name Type Details,col_02_Name Type Details,...);
14.先判斷再建立資料表:create table if not exists Table_Name(...);
15.複製資料表:create table Table_Name_01 select * from Table_Name_02;
16.重新命名資料表:alter table Table_Name rename as New_Table_Name;或者:rename table Old_Name to New_Name;
17.刪除資料表:drop table Table_Name;


18.向資料表添加紀錄:insert into Table_Name set col_01=Value1,col_02=Value2;
19.修改資料表中的記錄:update Table_Name set col_Name=New_Value where id=1;
20.刪除資料表中的記錄:delete from Table_Name;
21.帶條件刪除資料表中的記錄:delete from Table_Name where id=1;


22.#目前時間查看:select now();
23.#目前使用者:select user();
24.#當前資料庫程式版本:select version();
25.#目前狀態:show status;
26.#查看當前串連的使用者:show processlist;

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.