Windows下mysql的基礎操作

來源:互聯網
上載者:User

標籤:mon   結構   伺服器   基礎   資料   資料表   修改欄位   varchar   資料庫   

1.資料庫表操作:

  • - 首先啟動mysql伺服器,在安裝mysql的目錄下開啟cmd視窗,運行mysql:‘mysql.exe -hlocalhost -p3306 -uroot -p123456‘;
  • - 查看所有的資料庫: show databases;  -- create database my_database;
  • - use my_database; --> show tables; --> create table class(name varchar(10), room varchar(10))charset utf8; --> show tables like "%s"; -->
  •   查詢表的建立語句:show create table my_student; --> 省略冒號的寫法:show create table my_student\g     --> 另外一種輸出格式:
  •   show create table my_student\G
  • - 給表重新命名:rename table student to my_student;
  • - 查看資料表的表結構:desc 表名; -->describe 表名;  --> show columns from 表名;
  • - 給表添加新的欄位:alter table my_student add column id int first/after; 
  • - 修改欄位:修改通常是屬性或者資料類型;--> alter table 表名 mondify 欄位名 資料類型 [屬性] [位置]; --> alter table my_student modify number char(10) after id;
  • - 重新命名欄位:alter table 表名 change 舊欄位 新欄位 資料類型  [屬性]  [位置];
  •   alter table my_student change gender sex varchar(10) after id;
  • - 刪除欄位:刪除學生表中的年齡欄位(age) --> alter table my_student drop age;
  • - 刪除資料表:drop table 1,2,3...   --> drop table class;

Windows下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.