在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ 數(shù)據(jù)庫/ SQLite 創(chuàng)建數(shù)據(jù)庫
SQLite Having 子句
SQLite 運算符
SQLite 注入
SQLite Delete 語句
SQLite – Python
SQLite 數(shù)據(jù)類型
SQLite 簡介
SQLite 創(chuàng)建數(shù)據(jù)庫
SQLite Vacuum
SQLite Group By
SQLite 日期 & 時間
SQLite AND/OR 運算符
SQLite 刪除表
SQLite Distinct
SQLite Alter 命令
SQLite PRAGMA
SQLite 約束
SQLite 創(chuàng)建表
SQLite Like 子句
SQLite Limit 子句
SQLite Autoincrement
SQLite 子查詢
SQLite – C/C++
SQLite – PHP
SQLite 命令
SQLite Order By
SQLite Select 語句
SQLite Unions 子句
SQLite – Perl
SQLite – Java
SQLite 別名
SQLite 常用函數(shù)
SQLite Explain(解釋)
SQLite NULL 值
SQLite Glob 子句
SQLite 表達式
SQLite 視圖
SQLite Where 子句
SQLite Truncate Table
SQLite 索引
SQLite Insert 語句
SQLite 安裝
SQLite Indexed By
SQLite 分離數(shù)據(jù)庫
SQLite 觸發(fā)器
SQLite 語法
SQLite Joins
SQLite Update 語句
SQLite 附加數(shù)據(jù)庫
SQLite 事務

SQLite 創(chuàng)建數(shù)據(jù)庫

SQLite 的 sqlite3 命令被用來創(chuàng)建新的 SQLite 數(shù)據(jù)庫。您不需要任何特殊的權限即可創(chuàng)建一個數(shù)據(jù)。

語法

sqlite3 命令的基本語法如下:

    $sqlite3 DatabaseName.db

通常情況下,數(shù)據(jù)庫名稱在 RDBMS 內(nèi)應該是唯一的。

實例

如果您想創(chuàng)建一個新的數(shù)據(jù)庫 ,SQLITE3 語句如下所示:

    $sqlite3 testDB.db
    SQLite version 3.7.15.2 2013-01-09 11:53:05
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite>

上面的命令將在當前目錄下創(chuàng)建一個文件 testDB.db。該文件將被 SQLite 引擎用作數(shù)據(jù)庫。如果您已經(jīng)注意到 sqlite3 命令在成功創(chuàng)建數(shù)據(jù)庫文件之后,將提供一個 sqlite> 提示符。

一旦數(shù)據(jù)庫被創(chuàng)建,您就可以使用 SQLite 的 .databases 命令來檢查它是否在數(shù)據(jù)庫列表中,如下所示:

    sqlite>.databases
    seq  name             file
    ---  ---------------  ----------------------
    0    main             /home/sqlite/testDB.db

您可以使用 SQLite .quit 命令退出 sqlite 提示符,如下所示:

    sqlite>.quit
    $

.dump 命令

您可以在命令提示符中使用 SQLite .dump 點命令來導出完整的數(shù)據(jù)庫在一個文本文件中,如下所示:

    $sqlite3 testDB.db .dump > testDB.sql

上面的命令將轉(zhuǎn)換整個 testDB.db 數(shù)據(jù)庫的內(nèi)容到 SQLite 的語句中,并將其轉(zhuǎn)儲到 ASCII 文本文件 testDB.sql 中。您可以通過簡單的方式從生成的 testDB.sql 恢復,如下所示:

    $sqlite3 testDB.db < testDB.sql

此時的數(shù)據(jù)庫是空的,一旦數(shù)據(jù)庫中有表和數(shù)據(jù),您可以嘗試上述兩個程序?,F(xiàn)在,讓我們繼續(xù)學習下一章。