Ócáid
Mar 31, 11 PM - Apr 2, 11 PM
An ócáid foghlama SQL, Fabric and Power BI is mó. Márta 31 – 2 Aibreán. Bain úsáid as cód FABINSIDER chun $ 400 a shábháil.
Cláraigh inniuNí thacaítear leis an mbrabhsálaí seo a thuilleadh.
Uasghrádú go Microsoft Edge chun leas a bhaint as na gnéithe is déanaí, nuashonruithe slándála, agus tacaíocht theicniúil.
Applies to:
SQL Server
This article describes how to create a database in SQL Server by using SQL Server Management Studio or Transact-SQL.
To create a database in Azure SQL Database using T-SQL, see CREATE DATABASE.
A maximum of 32,767 databases can be specified on an instance of SQL Server.
The CREATE DATABASE
statement must run in autocommit mode (the default transaction management mode) and isn't allowed in an explicit or implicit transaction.
The master database should be backed up whenever a user database is created, modified, or dropped.
When you create a database, make the data files as large as possible based on the maximum amount of data you expect in the database.
Requires CREATE DATABASE
permission in the master
database, or requires CREATE ANY DATABASE
, or ALTER ANY DATABASE
permission.
To maintain control over disk use on an instance of SQL Server, permission to create databases is typically limited to a few SQL Server logins.
In Object Explorer, connect to an instance of the SQL Server Database Engine and then expand that instance.
Right-click Databases, and then select New Database.
In New Database, enter a database name.
To create the database by accepting all default values, select OK; otherwise, continue with the following optional steps.
To change the owner name, select (...) to select another owner.
Nóta
The Use full-text indexing option is always checked and dimmed because all user databases are full-text enabled.
To change the default values of the primary data and transaction log files, in the Database files grid, select the appropriate cell and enter the new value. For more information, see Add Data or Log Files to a Database.
To change the collation of the database, select the Options page, and then select a collation from the list.
To change the recovery model, select the Options page and select a recovery model from the list.
To change database options, select the Options page, and then modify the database options. For a description of each option, see ALTER DATABASE SET options.
To add a new filegroup, select the Filegroups page. Select Add and then enter the values for the filegroup.
To add an extended property to the database, select the Extended Properties page.
In the Name column, enter a name for the extended property.
In the Value column, enter the extended property text. For example, enter one or more statements that describe the database.
To create the database, select OK.
Connect to the Database Engine.
From the Standard bar, select New Query.
Copy and paste the following example into the query window and select Execute. This example creates the database Sales
. Because the keyword PRIMARY
isn't used, the first file (Sales_dat
) becomes the primary file. Because MB
or KB
aren't specified in the SIZE
parameter for the Sales_dat
file, it uses MB
and is allocated in megabytes. The Sales_log
file is allocated in megabytes because the MB
suffix is explicitly stated in the SIZE
parameter.
USE master;
GO
CREATE DATABASE Sales ON
(NAME = Sales_dat,
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\saledat.mdf',
SIZE = 10,
MAXSIZE = 50,
FILEGROWTH = 5)
LOG ON
(NAME = Sales_log,
FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\salelog.ldf',
SIZE = 5 MB,
MAXSIZE = 25 MB,
FILEGROWTH = 5 MB);
GO
For more examples, see CREATE DATABASE.
Ócáid
Mar 31, 11 PM - Apr 2, 11 PM
An ócáid foghlama SQL, Fabric and Power BI is mó. Márta 31 – 2 Aibreán. Bain úsáid as cód FABINSIDER chun $ 400 a shábháil.
Cláraigh inniuOiliúint
Modúl
Provision an Azure SQL database to store application data - Training
Find out what makes Azure SQL Database a good choice for your relational database, how to create the database from the portal and connect with Azure Cloud Shell.
Deimhniú
Microsoft Certified: Azure Database Administrator Associate - Certifications
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.
Doiciméadúchán
Lesson 1: Connecting to the Database Engine - SQL Server
Lesson 1: Connecting to the Database Engine
Connect to the SQL Server Database Engine - SQL Server
Learn how to connect to the Database Engine used by SQL Server and Azure SQL services
CREATE DATABASE (Transact-SQL) - SQL Server
Create database syntax for SQL Server, Azure SQL Database, Azure Synapse Analytics, and Analytics Platform System