Since Umbraco v10 ships with SQLite and no more SQLCE I figured it would be a good idea upgrade my old "compare post" about SQL Server vs SQLCE.
There is a big difference between the databases in that the data types are very different but I was surprised to see that SQLite supports many types of queries that SQL CE did not. The data types in SQLite is basically:
- NULL
- INTEGER
- REAL
- TEXT
- BLOB
This will be a "work in progress" blog post about the differences between SQL Server and SQLite and I will keep updating it when I find new cases.
Description |
Query-example |
SQL Serv. |
SQLCE |
Regular SELECT |
SELECT * FROM umbracoNode |
x |
x |
SELECT with Subquery in select-statement |
SELECT id, |
x |
x |
SELECT with Subquery in WHERE-statement |
SELECT id, [text] |
x |
x |
SELECT with Subquery (scalar1) in WHERE |
|
x |
x5 |
SELECT with Inner Join |
SELECT n.id, n.[text] |
x |
x |
SELECT with STUFF-function |
SELECT id,[text], STUFF([text],1,1, '') |
x |
|
SELECT TOP |
SELECT TOP 5 * FROM cmsContentType |
x |
x5 |
SELECT with “FOR XML PATH”. |
SELECT TOP 10 id,[text] |
x |
|
Row_Number() / Paging with |
SELECT id,[text], |
X |
X |
Paging with |
SELECT id,[text] |
X |
X |
SELECT DISTINCT-feature |
SELECT DISTINCT Id from umbracoContentVersion ORDER BY Id |
X |
X |
SELECT COUNT with DISTINCT3 |
SELECT COUNT(DISTINCT thumbnail) FROM cmsContentType |
X |
X |
SELECT with LIKE in Where |
SELECT * |
X |
X |
SELECT with Subquery in FROM-statement. |
SELECT count(contentId) |
X |
X |
SELECT with LEFT OUTER JOIN |
SELECT n.id, n.[text], d.text, d.preventCleanup FROM umbracoNode as n |
X |
X |
Parameter Alias declared as string |
SELECT id as 'foo' FROM umbracoNode |
X |
X |
Parameter Alias declared inline |
SELECT id as foo FROM umbracoNode |
X |
X |
SELECT with INNER JOIN Subquery in FROM |
SELECT * FROM cmsTemplate as t |
X |
X |
CROSS APPLY |
SELECT id,userName,ugr.Roles FROM umbracoUser u |
X |
|
DATEPART |
SELECT DATEPART(YEAR, createDate) AS [Year] |
X |
|
CAST4 |
SELECT CAST(id as text) textId FROM umbracoNode |
X |
X* |
DATALENGTH6 |
SELECT DATALENGTH([text]) textId FROM umbracoNode |
X |
X* |
UNION ALL |
SELECT id,userLogin as [email] FROM umbracoUser |
X |
X |
CONVERT |
SELECT CONVERT(nvarchar(50), uniqueId) as data3 FROM umbracoNode |
X |
|
....
1. A scalar query is a query that returns one row consisting of one column.
2. Works on SQL Server 2012+, older versions need the ROW_NUMBER()
3. Another version of the query with a join in the FROM-caluse works on SQL CE: SELECT COUNT(thumbs.total) as Total FROM (SELECT DISTINCT thumbnail as total FROM cmsContentType) as thumbs
4. Since the column data types are not the same (SQL Server has nvarchar, varchar while SQLite uses TEXT) this needs to be handled.
5. SELECT TOP is not supported in SQLite. But if the subquery was SELECT nodeId from umbracoContentVersion LIMIT 1 it would work.
6. SQLite calls this function length, used like so: length([columnName])