mysql8基礎 primary key auto_increment 創建主鍵、自增長的字段

  •        OS : Ubuntu 18.04.1 LTS
  •        DBMS : mysql 8.0.12
  •        blog : blog.csdn.net/shiwanwu
  •  typesetting : Markdown

數據,數據,命根就在數據 ! 操作數據庫時,一定要謹慎小心。師萬物 的代碼看看就好,要有自己的判斷。遇到抉擇,要不恥上下問。

example

stu@Ubuntu:~$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 25
Server version: 8.0.12 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use db_chinese_medicine;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> create table `t_primary_auto_test`(
    -> `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主鍵,自增長',           
    -> PRIMARY KEY (`id`)                                                           
    -> )                                                                            
    -> ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='測試表';                                                                       
Query OK, 0 rows affected (0.10 sec)

mysql> desc t_primary_auto_test;
+-------+------------------+------+-----+---------+----------------+
| Field | Type             | Null | Key | Default | Extra          |
+-------+------------------+------+-----+---------+----------------+
| id    | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
+-------+------------------+------+-----+---------+----------------+
1 row in set (0.01 sec)

mysql> exit
Bye
stu@Ubuntu:~$ 

reference

resource


MySQL是關係型數據庫管理系統,目前是開源的(2019-02)。
明確權限,恰當地選擇引擎與字符集等,規範命名。
MariaDB,Redis,MongoDB,PostgreSQL,Hive,HBase等,多作了解,拓寬心量。
Workbench,phpMyAdmin,Navicat等圖形化管理工具,豫兮若冬涉川。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章