Difference between SQL and other databases in Sqlite, sqlitesql

Source: Internet
Author: User

Difference between SQL and other databases in Sqlite, sqlitesql

Sqlite is widely used as a mainstream database in Android, but its SQL language is different from the SQL language used by general large databases. This article summarizes the following:

1. TOP

In SQL Server, TOP is used to obtain the first N data records:

SELECT TOP 10 * FROM [index] ORDER BY indexid DESC;

But in Sqlite, we will find that this is not feasible. We need to write this:

SELECT * FROM [index] ORDER BY indexid DESC limit 0,10;

Use limit to implement the TOP function.

2. COUNT (DISTINCT column)

Sqlite cannot execute the following statement:

SELECT COUNT(DISTINCT watchid) FROM [watch_item] WHERE watch_item.watchid = 1;

The reason is that all built-in functions of SQLite do not support DISTINCT limitation. Therefore, it is troublesome to count the number of records that are not repeated. It is feasible to create a view of the record table that does not repeat, and then count the view. Or when inserting data, you need to use the primary key to determine.

3. Sqlite cannot use external connection

Please advise if you have any solutions ....

4. EXISTS statement

SQL Server writes:

IF NOT EXISTS (select * from aa where ids=5) BEGIN insert into aa(nickname) select 't' END 

Sqlite writes:

insert into aa(nickname) select 't' where not exists(select * from aa where ids=5)

If you have something new, please leave a message to add it.

Above.











What is the difference between sqlite and sqlyog? Which one is better?

Hello, Questioner:
SQLite is a database, and currently the most widely used is android development.
SQLyog is a visual MySQL database management interface.
MySQL is a database and a small and easy-to-use database. It is essential for beginners.
Sun Cheng [authoritative expert]

What is the difference between sqlite3 and mysql databases?

The simplest difference: SQLite3 is a single-host data that cannot be used in the network. It is generally used to make desktop single-host small programs, such as small dictionaries.
MYsql is mostly used for creating web pages.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.