Export (0) Print
Expand All
Expand Minimize
0 out of 1 rated this helpful - Rate this topic

Creates a new database and the file that is used to store the database.



CREATE DATABASE databaseName 
   [DATABASEPASSWORD '<enterStrongDatabasePasswordHere>' 
      [ENCRYPTION {ON|OFF}] 
   ]
   [COLLATE collationNamecomparisonStyle] 
database password ::= identifier
databaseName

The name of the new database. The databaseName argument is a file name and is restricted by the naming and size limitations of the operating system. Any valid character that can be used in a file name can be used for the database name. If a path name is not specified, the database is created in the current directory. By default, the file name extension for a database name in SQL Server Compact 3.5 is .sdf.

'<enterStrongDatabasePasswordHere>'

SQL Server Compact 3.5 returns an error if a user connects to a password-protected database without a password. The database password must be enclosed in single quotation marks.

ENCRYPTION

If the optional ENCRYPTION ON keyword is used, the database is encrypted by using 128-bit encryption. You must specify a password to use encryption.

collationName

Specifies the default collation for the database. The collationName argument can only be a Windows collation. If collationName is not specified, the database is assigned the default collation of the device. For a list of collation names, see COLLATE (SQL Server Compact).

comparisonStyle

Specifies the comparison style of characters. The collationName and comparisonStyle parameters must not be enclosed in single or double quotation marks. SQL Server Compact 3.5 supports only CI_AS (case insensitive and accent sensitive) through the CREATE DATABASE statement. .

Starting with the SQL Server Compact 3.5 SP1 release, case-sensitive collations are also supported. However, this support is only available through the native and managed programming APIs. For more information, see Working with Collations (SQL Server Compact) and Supported Collations (SQL Server Compact).


To execute the CREATE DATABASE statement, you must be connected to a database. For information about how to connect to a database, see SQL Server Compact Query Analyzer.

A. Creating a password-protected database

The following example creates a database that uses a password.

CREATE DATABASE "\test1.SDF" DATABASEPASSWORD '<enterStrongPasswordHere>'

When a user tries to connect to a password-protected database without supplying the correct password, SQL Server Compact 3.5 returns an error. For information about errors, see SQL Server Compact Errors.

B. Creating a database that has a collation specified

The following example specifies a specific collation for the database being created.

CREATE DATABASE "SpanishDB.sdf" DATABASEPASSWORD '<enterStrongPasswordHere>' COLLATE Traditional_Spanish_CI_AS

Note   When you create a new database, make sure that the correct collation is specified. If a table name is long and has mixed characters such as English and Japanese, the table might not be recognized in the subsequent connections to the database.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.