How similar is sqlite to mysql iPhone
I was just thinking about databases on the iPhone, and I wondered what I need to know to c开发者_如何学Code sqlite on the iPhone. What are its similarities and differences to MySQL?
Thanks
Here is a really good comparison site for different SQL dialects:
- http://en.wikibooks.org/wiki/SQL_Dialects_Reference
To quickly summarize the differences, here are a few:
MySQL
- Requires a username and password to connect.
- Identifiers are escaped by `
- Concatenates two strings with CONCAT()
Utilizes the following join types:
- CROSS
- INNER
- LEFT
- LEFT OUTER
- RIGHT
- RIGHT OUTER
- NATURAL
- NATURAL LEFT
- NATURAL LEFT OUTER
- NATURAL RIGHT
- NATURAL RIGHT OUTER
- STRAIGHT
Utilizes the following set operators:
- UNION
- UNION ALL
- UNION DISTINCT
SQLite
- Does not require a username and password to connect.
- Identifier are escaped by []
- Concatenates two string with ||
Utilizes the following join types:
- CROSS
- INNER
- LEFT
- LEFT OUTER
- NATURAL
- NATURAL CROSS
- NATURAL INNER
- NATURAL LEFT
- NATURAL LEFT OUTER
Utilizes the following set operators:
- EXCEPT
- INTERSECT
- UNION
- UNION ALL
There are some other differences when writing expression such as:
MySQL
- REGEX
SQLite
- REGEXP
- GLOB
- NOT GLOB
- MATCH
- NOT MATCH
To help you build queries, you can use https://github.com/ziminji/objective-c-sql-query-builder
If you want to compare the basic CRUD statements, here are some links to check out:
MySQL
- DELETE: http://dev.mysql.com/doc/refman/5.0/en/delete.html
- INSERT: http://dev.mysql.com/doc/refman/5.5/en/insert.html
- SELECT: http://dev.mysql.com/doc/refman/5.0/en/select.html
- UPDATE: http://dev.mysql.com/doc/refman/5.0/en/update.html
SQLite
- DELETE: http://www.sqlite.org/lang_delete.html
- INSERT: http://www.sqlite.org/lang_insert.html
- SELECT: http://www.sqlite.org/lang_select.html
- UPDATE: http://www.sqlite.org/lang_update.html
the sql language is pretty similar but not identical. The most annoying difference is that in sqlite you can't get a count of the records that match a query.
If you know SQL, then SQLite is like piece of cake. You can make use of the plugin provided in Firefox for SQLite and kick start with SQLite.
The SQL syntax is fairly similar across both implementations. However, SQLLite is farther from being / accepting the full SQL language. Last time I tried using SQLLite I was forced to convert a RIGHT JOIN
to a LEFT JOIN
by changing around the table order.
use this url and use this concept .....
http://dblog.com.au/iphone-development-tutorials/iphone-sdk-tutorial-reading-data-from-a-sqlite-database/
http://www.code2design.com/tutorial/convert_mysql_tables_to_sqlite_tables#comment-4543
精彩评论