Get the App
SLTechnology News&Howtos  ›  Servers  › 

Addition, deletion, modification and query of database Sqlite files

Shulou Source: shulou.com Published: 2022-06-03 01:12:03 09月20日 Update

We have a section in the previous sections about the creation and addition of database sqlite files. Let's continue with that section. First of all, look at the picture: the data saved last time

Now we learn how to use SQL statements to add data.

There are two kinds of adding data, one is to add part of the data, the other is to add all the data.

Let's first look at adding some data, syntax:

Insert into table name (field name 1, field name 2) Values (value 1, value 2,)

The table name is the name of table. We are position. The field is the name of each item of data in the table. For example, X, Y, Z. The value is the value corresponding to the field (the order of the field name and value must correspond well).

Let's write down the example sentence under the SQL menu as shown in the picture

Then click "Execute". If there is no problem, it will be added. Then select the data menu and click on the table position. As shown in the picture

The second line is our newly added data. Because only the x and y fields have been added. So everything else is null.

There is no distinction between upper and lower case letters in the code. But the words can not be written wrong, otherwise the addition will not be successful. That kind of situation is basically caused by word errors.

Next, let's add all the data. Syntax:

Insert into table name values (1 value, 2 value.)

There is no need to write the field name, just assign all the values. But be aware that all values are assigned.

The example sentence is as follows

Also click "Excute". Don't make a mistake. Then select data and click on the table position.

As shown in the picture

Next, let's look at the statement syntax for deleting data:

Delete from table name where (condition)

Condition is based on what to delete, for example, x = 2.5. The example sentences are as follows

After clicking OK

The data in the second row has been deleted.

Next, let's learn the sentence syntax for changing the data:

Update table name set field name = "new value" where field name = "old value"

Example:

And then

Finally, we learn the sentence syntax for querying data. There are also two kinds of this.

Query partial data statement syntax:

Select field name from table name where (field name = some value)

Query the value of a field name in the table according to the condition

As shown in the picture

The result we found is cube, correct.

Finally, we learn the sentence syntax for querying all data:

Select * from table name where field name = a value

Note that the "*" number must be available. The example sentences are as follows

We find out all the data for the row based on the value of a field name.

That's what we're talking about in this section. In the next section, we will discuss how to add, delete, modify and query the database in unity.

Tags: Data name field that is grammar statement example sentence such as figure study query next condition table part database content word name menu select Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Huawei Shulou Technology Shulou Information Docker