1. 程式人生 > >使用MySQL Workbench建立資料庫,建立新的表,向表中新增資料

使用MySQL Workbench建立資料庫,建立新的表,向表中新增資料

初學資料庫,記錄一下所學的知識。我用的MySQL資料庫,使用MySQL Workbench管理。下面簡單介紹一下如何使用MySQL Workbench建立資料庫,建立新的表,為表新增資料。

點選上圖中的“加號”圖示,新建一個連線,

如上圖,先輸入資料庫的賬號密碼,帳號預設為root,填好密碼後 點選“OK”,連線就建立好了,建立完成後,會出現一個長方形的框框,雙擊它,出現下圖所示頁面

點選圖中的紅圈裡的按鈕,新建一個Schema,即資料庫(個人理解。。),修改一下Name 的值,如  mydatabase ,點選apply,再點apply,然後點finish  如下圖所示

資料庫就建好了!!! 如圖

接下來就是如何建立表,

首先要     !!!雙擊!!!    一下剛剛建立好的資料庫mydatabase,然後再建立表,不然會出錯,右鍵點選Tables 然後點選Create new tables ,填寫表名,以及表列的資訊,之後點選  apply ,一張表就建完了

 PK: primary key (column is part of a pk)  主鍵

 NN: not null (column is nullable)  是否為空

-UQ: unique (column is part of a unique key)  外來鍵

 AI: auto increment (the column is auto incremented when rows are inserted)  自動增加

  BIN: binary (if dt is a blob or similar, this indicates that is binary data, rather than text)   二進位制

 UN: unsigned (for integer types, see docs: “10.2. Numeric Types”)

- ZF: zero fill (rather a display related flag, see docs: “10.2. Numeric Types”)

 出現如下頁面

接下來向建好的tb_student表中新增資料

右鍵點選tb_student,再點選select rows  limit 1000

在mysql workbench中向資料庫中的表中新增資料大致就是這個樣子。