DBA:多方式建庫表資料庫表

來源:互聯網
上載者:User

標籤:符號   -o   .com   lin   技術   serve   編碼   src   root   

提醒:
建立 MySql 的表時,表名和欄位名外面的符號 ` 不是單引號,而是英文IME狀態下的反單引號,鍵盤左上方 esc 按鍵下面的那一個 ~ 按鍵。

在每一條語句的終止符都是‘;’

一、命令列建庫表

[[email protected] ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 36
Server version: 5.7.18-log Source distribution

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

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

MySQL [(none)]> create database linuxview;
Query OK, 1 row affected (0.00 sec)

MySQL [(none)]> use linuxview;
Database changed
MySQL [linuxview]> create table lv1(id int(4),name varchar(10),mark varchar(10)) engine=innodb default charset=utf8;
Query OK, 0 rows affected (0.40 sec)

MySQL [linuxview]> show tables;
+---------------------+
| Tables_in_linuxview |
+---------------------+
| lv1 |
+---------------------+
1 row in set (0.00 sec)

MySQL [linuxview]>

說明:
如果不想欄位為空白,可以在欄位屬性後添加 not null,在插入資料的時如果該欄位為NULL會報錯。
engine設定搜尋引擎
charset設定編碼

二、PHP建庫表

文法:
mysqli_query(connection,query,resultmode);

{
die(‘建立資料庫失敗:‘ . mysqli_query($conn));
}
echo "建立資料表成功\n";
mysqli_close($conn);
?>
[[email protected] web]#

效果:

查看資料庫:
MySQL [(none)]> use viewtest;
Database changed
MySQL [viewtest]> show tables;
+--------------------+
| Tables_in_viewtest |
+--------------------+
| lv1 |
+--------------------+
1 row in set (0.00 sec)

MySQL [viewtest]>

DBA:多方式建庫表資料庫表

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.