Lightweight SQL database which doesn't require

2019-01-07 13:03发布

问题:

Could you recommend a lightweight SQL database which doesn't require installation on a client computer to work and could be accessed easily from .NET application? Only basic SQL capabilities are needed.

Now I am using Access database in simple projects and distribute .MDB and .EXE files together. Looking for any alternatives.

回答1:

Depends on what you mean by lightweight. Easy on Ram? Or lighter db file? Or lighter connector to connect to db? Or fewer files over all? I'll give a comparison of what I know:

                    no of files    cumulative size of files    db size

Firebird 2.5             5                6.82 MB               250 KB

SqlServerCe 4            7                2.08 MB               64 KB

Sqlite 3.7.11.0          1                0.83 MB               15 KB

VistaDb 4.3.3.34         1                1.04 MB               48 KB

no of files - includes the .net connector and excludes the db file

The dbs are of 1 table with 2 columns and 2 rows. Take the db size with a pinch of salt as dbs could grow differently with further use. For instance SqlServerCe though initially was at 64 KB, it didn't grow at all after adding a few hundred records, while VistaDb grew easily from 48 to 72 to 140 KB. SQLite was the best in that regard which started from the lowest and grew linearly.

Few anecdotes: I had better performance using SqlServerCe with the factory settings which means its the easiest to get kick started without any configuration, while I found Firebird little bit harder to get it started due to lack of online materials. Firebird as I could read had widest standard sql compliance. While VistaDb is written in fully managed C# which means it can be merged with your application's assembly to have one single file, it seemed slowest to me. Of all, considering performance, ease and size I chose SQLite. SqlServerCe would be my second choice.

In short each has its pluses and minuses. Again, take my rant with a pinch of salt, its just my personal experience.



回答2:

Check SQLite, it's a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.

It has many wrappers for .NET



回答3:

Howabout SQL Server 3.5/2008 Compact Edition? A neat embedded version of SQL Server.

http://www.microsoft.com/Sqlserver/2008/en/us/compact.aspx

Works pretty nice with .NET, and of course all your regular SQL Server tools and scripts work fine.



回答4:

You could look at VistaDB if you are writing in .NET. It is 100% managed code, contains true referential integrity, tsql stored procs, clr procs, and much more in a single assembly you can xcopy deploy.

VistaDB runs in shared hosting asp.net sites under medium trust, and in active directory domains as guest (no local permissions) as well.

There are no registry or other configuration settings required on the machine you deploy the engine on, and the runtime is royalty free.

32/64 bit support is included in the single assembly. Mixed mode engines with unmanaged code generally require you to ship more than 1 version of the unmanaged code to support 32 and 64 bit, or to recompile for specific CPU targets.

See the Advantages of VistaDB SO thread for more information.

http://www.vistadb.net



回答5:

SQLite is great.

Also check out Firebird embedded. It might be a better option if multiple users need to access the database in the future.



回答6:

You can store your data as JSON files. If you need it to be stand-alone, there are dll solutions such as IODB and LiteDB



回答7:

SQLite will be what you're after