In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this article, the editor introduces in detail "how to install and use SQLite3 under Linux". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to install and use SQLite3 under Linux" can help you solve your doubts.
SQLite3 is an embedded database, and its database is a file. Because SQLite3 itself is written in C and is very small, it is often integrated into a variety of applications, even in the App of iOS and Android.
One. Install database and create a database under linux
\ 1. It takes two commands to install sqlite3 under Linux.
(1) sudo apt-get install sqlite
(2) sudo apt-get install libsqlite3-dev
\ 2. After installation, create a database and enter the command [sqlite3 database name] under the terminal. The database name ends in .db format.
Create database student.db [sqlite3 student.db]
Two. Database commands begin with [.]; database statements end with [;]
\ 1. Database command
(1) .schema table name shows the table structure such as: [.schema student]
(2) [.tables] display table
(3) [.exit] or [.exit] exit the database control interface
\ 2. Database statement
(1) create a data table: student [create table student (id int primary key,name char,age int,sex char)
(2) insert the data insert into table name values (value 1, value 2, value 3, value 4) into the table; for example: [insert into student values (0zhang0zhang0pm 20pm');] if no error message is returned, the insert is successful.
(3) find the table name of the statement select * from
All contents of the lookup table are displayed [select * from student;]
Find a field (column information) [select id from student;]
Find [select * from student where age > 25 and sex='m'] {conditional and or represents and, or} according to a condition
(4) modify a content update table name set column name = new value where condition, for example: change the name of zhang0 to liwang [update student set name='liwang' where name='zhang0';]
(4) delete a message: delete from table name where condition; for example: delete a line whose name is hello [delete from student where name='hello';]
(5) add a column: alter table table name add column name data type; [alter table student add address char;]
[update student set address='beijing';] Update all address fields to beijing
(5) Delete a table drop table table name; [drop table soc;]
(6) sqlite3 does not support deleting a column of information. You can copy the required columns in the original table to a new table and rename: create table new table name as select column name 1, column name 2, column name 3, column name 4 from old table name
[create table stu as select id,name,sex from student;] Select the id,name,sex field in the student table as the field for the new table
(7) rename the table: alter table old table name rename to new table name; [alter table stu rename to student_new;]
(8) select count (*) from sqlite_master where * type= "table" and name = "table name";
Note: indicates that the string can be "or" the end of the SQL statement must be a semicolon.
After reading this, the article "how to install and use SQLite3 under Linux" has been introduced. If you want to master the knowledge of this article, you still need to practice and use it yourself. If you want to know more about the article, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.