SQL Server DATABASE creation script Create DATABASE, createdatabase
Create DATABASE HappyRelaxDBon( NAME='HappyRelaxDB',FILENAME='D:\Sunny_Project\HappyRelaxPro\HappyRelaxDB.mdf')LOG ON(NAME='HappyRelaxDB_log',FILENAME='D:\Sunny_Project\HappyRelaxPro\HappyRelaxDB_log.ldf')GO
The above marked yellow is the content to be changed
SQL Server 2008 how to create a database using SQL scripts
Suppose you create a database abc and a user table:
If not exists (SELECT name FROM master. dbo. sysdatabases WHERE name = n'abc ')
BEGIN
Create database [abc] ON (NAME = n' abc _ data', FILENAME = n' D: \ abc_Data.MDF ', SIZE = 12, FILEGROWTH = 10%) log on (NAME = n' abc _ log', FILENAME = n' D: \ abc_log.ldf', SIZE = 10, FILEGROWTH = 10%)
COLLATE Chinese_PRC_CI_AS
END
GO
Create table [abc]. [user] (
[UserID] [GUID] not null,
[User name] [varchar] (255) COLLATE Chinese_PRC_CI_AS not null,
[Password] [varchar] (255) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
For the sql-server2005, how to write the program to achieve table creation, create database book write with create, but where to write the create statement
In your SQLSERVER, click Create query in the upper left corner, and a drop-down list is displayed on the top of the new query. You can select the database where you want to create a table and select the table.
You can use the SQL server designer to create a database, or use SQL statements.
Use master -- set the current database as the master to facilitate access to the table sysdatabases
If exists (select * from sysdatabases where name = 'database') -- query whether stuDB database exists
Drop database stuDB -- delete the database if it exists
Go
Create database stuDB
On primary
(
Name = 'database'
, Finename = 'd: \ stuDB. mdf'
, Size = 3 mb
Filegrowth = 10%
, Maxsize = unlimited
)
Log on
(
Name = 'db _ Log'
, Filename = 'd: \ stuDB_log.ldf'
, Size = 3 mb
Filegrowth = 10%
, Maxsize = unlimited
)
Create a table
If exists (select * from sysobjects where name = 'stuinfo ')
Drop table stuInfo
Go
Create table stuInfo
(
StuName varchar (50) not null
, StuAge int not null
)