下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
sqlite3 test.db // open sqlite and provide a database name // Creates a table in the database // Primary Key automatically generates values that start at 1 and increase by 1 // name is a text field that will hold employee names create table employees (id integer primary key,name text); // Insert some employees insert into employees (id,name) values(1,'Max Eisenhardt'); insert into employees (name) values('Pietro Maximoff'); insert into employees (name) values('Wanda Maximoff'); insert into employees (name) values('Mortimer Toynbee'); insert into employees (name) values('Jason Wyngarde'); // In column mode,each record is shown on a separate line with the data aligned in columns // headers on shows the column names,if off they wouldn't show .mode column .headers on select * from employees; // Show all employees // Changes the width of the columns .width 15 20 .exit // Closes the database sqlite3 test.db // Reopen database .tables // displays the tables // displays every value on its own line .mode line select * from employees; // Shows the statements used to create the database. You Could also provide a table name to see how that single table was made .schema OR .schema employees // You can get a more detailed database view .mode column .headers on select type,name,tbl_name,sql from sqlite_master order by type; // Used to show the current settings .show // Set NULL to 'NULL' .nullvalue 'NULL' .show // Change the prompt for sqlite .prompt 'sqlite3> ' .show // Used to export database into sql format on the screen .dump // Used to output to a file .output ./Documents/sqlite3Files/employees.sql .dump .output stdout // Restores output to the screen // You don't delete a database with any command. You have to delete the file itself // You can delete a table however drop table employees; // You can import the table then with .read ./Documents/sqlite3Files/employees.sql // .mode is used to change the formatting of the output // OPTIONS FOR MODE : column,csv // html: html table // insert: insert commands used // list: List without commas // tabs: Tab separated list // How to output a CSV list to a file .mode csv // You Could define the output should be csv .separator,// OR define the separator for the columns .output ./Documents/sqlite3Files/employees.csv .separator,select * from employees; .output stdout // Output html table .mode html select * from employees; .output stdout // line outputs column name and value .mode line select * from employees; .output stdout // Items with double quotes .mode tcl select * from employees; .output stdout
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。