Mac通过终端查看Sqlite

约定不等于承诺〃 2022-11-16 01:49 543阅读 0赞
  • 打开数据库:sqlite3 + 数据库路径

    ~ sqlite3 /Users/tangbincheng/Documents/develope/DjangoDemo/mysite/db.sqlite3
    SQLite version 3.28.0 2019-04-15 14:49:49
    Enter “.help” for usage hints.
    sqlite>

  • 查看数据库表有哪些:.tables

    sqlite> .tables
    account_userprofile auth_user_user_permissions
    auth_group blog_blogarticles
    auth_group_permissions django_admin_log
    auth_permission django_content_type
    auth_user django_migrations
    auth_user_groups django_session

  • 选择记录:其实就是常用的sql语句的使用了,再次提醒,一定要记到是在英文输入法环境下,因为终端空格是察觉不出来是英文还是中文环境下。

    sqlite> select * from account_userprofile;
    1|2000-12-25|18688550018|4

  • 退出:

    .quit

更多的使用方法,建议用-help或者man这种方式来查看提示。比如

  1. ~
  2. sqlite3
  3. SQLite version 3.28.0 2019-04-15 14:49:49
  4. Enter ".help" for usage hints.
  5. Connected to a transient in-memory database.
  6. Use ".open FILENAME" to reopen on a persistent database.
  7. sqlite> .help
  8. .auth ON|OFF Show authorizer callbacks
  9. .backup ?DB? FILE Backup DB (default "main") to FILE
  10. .bail on|off Stop after hitting an error. Default OFF
  11. .binary on|off Turn binary output on or off. Default OFF
  12. .cd DIRECTORY Change the working directory to DIRECTORY
  13. .changes on|off Show number of rows changed by SQL
  14. .check GLOB Fail if output since .testcase does not match
  15. .clone NEWDB Clone data into NEWDB from the existing database
  16. .databases List names and files of attached databases
  17. .dbconfig ?op? ?val? List or change sqlite3_db_config() options
  18. .dbinfo ?DB? Show status information about the database
  19. .dump ?TABLE? ... Render all database content as SQL
  20. .echo on|off Turn command echo on or off
  21. .eqp on|off|full|... Enable or disable automatic EXPLAIN QUERY PLAN
  22. .excel Display the output of next command in a spreadsheet
  23. .exit ?CODE? Exit this program with return-code CODE
  24. .expert EXPERIMENTAL. Suggest indexes for specified queries
  25. .fullschema ?--indent? Show schema and the content of sqlite_stat tables
  26. .headers on|off Turn display of headers on or off
  27. .help ?-all? ?PATTERN? Show help text for PATTERN
  28. .import FILE TABLE Import data from FILE into TABLE
  29. .imposter INDEX TABLE Create imposter table TABLE on index INDEX
  30. .indexes ?TABLE? Show names of indexes
  31. .limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT
  32. .lint OPTIONS Report potential schema issues.
  33. .log FILE|off Turn logging on or off. FILE can be stderr/stdout
  34. .mode MODE ?TABLE? Set output mode
  35. .nullvalue STRING Use STRING in place of NULL values
  36. .once (-e|-x|FILE) Output for the next SQL command only to FILE
  37. .open ?OPTIONS? ?FILE? Close existing database and reopen FILE
  38. .output ?FILE? Send output to FILE or stdout if FILE is omitted
  39. .parameter CMD ... Manage SQL parameter bindings
  40. .print STRING... Print literal STRING
  41. .progress N Invoke progress handler after every N opcodes
  42. .prompt MAIN CONTINUE Replace the standard prompts
  43. .quit Exit this program
  44. .read FILE Read input from FILE
  45. .restore ?DB? FILE Restore content of DB (default "main") from FILE
  46. .save FILE Write in-memory database into FILE
  47. .scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off
  48. .schema ?PATTERN? Show the CREATE statements matching PATTERN
  49. .selftest ?OPTIONS? Run tests defined in the SELFTEST table
  50. .separator COL ?ROW? Change the column and row separators
  51. .session ?NAME? CMD ... Create or control sessions
  52. .sha3sum ... Compute a SHA3 hash of database content
  53. .shell CMD ARGS... Run CMD ARGS... in a system shell
  54. .show Show the current values for various settings
  55. .stats ?on|off? Show stats or turn stats on or off
  56. .system CMD ARGS... Run CMD ARGS... in a system shell
  57. .tables ?TABLE? List names of tables matching LIKE pattern TABLE
  58. .testcase NAME Begin redirecting output to 'testcase-out.txt'
  59. .timeout MS Try opening locked tables for MS milliseconds
  60. .timer on|off Turn SQL timer on or off
  61. .trace ?OPTIONS? Output each SQL statement as it is run
  62. .vfsinfo ?AUX? Information about the top-level VFS
  63. .vfslist List all available VFSes
  64. .vfsname ?AUX? Print the name of the VFS stack
  65. .width NUM1 NUM2 ... Set column widths for "column" mode

发表评论

表情:
评论列表 (有 0 条评论,543人围观)

还没有评论,来说两句吧...

相关阅读