Sqlite3显示数据库、显示表命令(与mysql对比)

本文对比了SQLite和MySQL两种数据库管理系统中的常用命令,包括显示数据库、切换数据库、显示表等操作,对于初学者理解这两种数据库的基本使用非常有帮助。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

注:中括号[]里面为可选项

显示数据库:

sqlite:.database

mysql:show databases;(这个可以没有分号)


切换数据库:

sqlite:帮助并没有说明,应该没有吧,虽然可以附加

mysql: use dbName


显示表:

sqlite:.table [tableName]

mysql:show tables;


显示表结构:

sqlite:select * from sqlite_master where type = "table";(先设置表头显示,不然你看得会很懵逼,命令为:.header on

mysql:desc tableName;


显示建表语句:

sqlite:.schema [tableName]

mysql: show create table tableName;


退出命令行:

sqlite:.quit / .exit / ctrl+C

mysql:quit / exit


最后贴出完整的.help帮助文档

.help
.backup ?DB? FILEBackup DB (default "main") to FILE
.bail on|off  Stop after hitting an error.  Default OFF
.binary on|off Turn binary output on or off.  Default OFF
.clone NEWDB Clone data into NEWDB from the existing database
.databasesList names and files of attached databases
.dbinfo ?DB? Show status information about the database
.dump ?TABLE? ... Dump the database in an SQL text format
                         If TABLE specified, only dump tables matching
                         LIKE pattern TABLE.
.echo on|off Turn command echo on or off
.eqp on|off Enable or disable automatic EXPLAIN QUERY PLAN
.exit Exit this program
.explain ?on|off? Turn output mode suitable for EXPLAIN on or off.
                         With no args, it turns EXPLAIN on.
.fullschemaShow schema and the content of sqlite_stat tables
.headers on|offTurn display of headers on or off
.helpShow this message
.import FILE TABLEImport data from FILE into TABLE
.indexes ?TABLE?Show names of all indexes
                         If TABLE specified, only show indexes for tables
                         matching LIKE pattern TABLE.
.limit ?LIMIT? ?VAL?Display or change the value of an SQLITE_LIMIT
.log FILE|off Turn logging on or off.  FILE can be stderr/stdout
.mode MODE ?TABLE?Set output mode where MODE is one of:
                         ascii    Columns/rows delimited by 0x1F and 0x1E
                         csv      Comma-separated values
                         column   Left-aligned columns.  (See .width)
                         html     HTML <table> code
                         insert   SQL insert statements for TABLE
                         line     One value per line
                         list     Values delimited by .separator strings
                         tabs     Tab-separated values
                         tcl      TCL list elements
.nullvalue STRINGUse STRING in place of NULL values
.once FILENAMEOutput for the next SQL command only to FILENAME
.open ?FILENAME? Close existing database and reopen FILENAME
.output ?FILENAME?Send output to FILENAME or stdout
.print STRING... Print literal STRING
.prompt MAIN CONTINUEReplace the standard prompts
.quitExit this program
.read FILENAMEExecute SQL in FILENAME
.restore ?DB? FILERestore content of DB (default "main") from FILE
.save FILE Write in-memory database into FILE
.scanstats on|offTurn sqlite3_stmt_scanstatus() metrics on or off
.schema ?TABLE? Show the CREATE statements
                         If TABLE specified, only show tables matching
                         LIKE pattern TABLE.
.separator COL ?ROW?Change the column separator and optionally the row
                         separator for both the output mode and .import
.shell CMD ARGS...Run CMD ARGS... in a system shell
.showShow the current values for various settings
.stats on|offTurn stats on or off
.system CMD ARGS...Run CMD ARGS... in a system shell
.tables ?TABLE? List names of tables
                         If TABLE specified, only list tables matching
                         LIKE pattern TABLE.
.timeout MSTry opening locked tables for MS milliseconds
.timer on|off Turn SQL timer on or off
.trace FILE|offOutput each SQL statement as it is run
.vfsname ?AUX? Print the name of the VFS stack
.width NUM1 NUM2 ...Set column widths for "column" mode
                         Negative values right-justify

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值