-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01-Create.sql
More file actions
53 lines (37 loc) · 1.42 KB
/
01-Create.sql
File metadata and controls
53 lines (37 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
Creating and altering a database
A SQL Server database can be created, altered and dropped
1. Graphically using SQL SERVER MABAFENENT studio (SSMS) or
2. Using Query
To create the database using query
Create database "DatabaseName"
Whether you careate a database graphically using the designer or using
a query, the following2 files fet generated
.MDF file -> Data files (contains actual data)
.LDF file -> Transaction log file(Used to recover the database0
To Alter a database inece it's ceated
alter database "Database Name" modiy name = "NewDatabase Name"
Alternative you can also use system stored procedure
Execute sp_renameDB 'OldDatabaseName','NewDatabaseName'
*/
/*
Creating and altering a database
A SQL Server database can be created, altered and dropped
1. Graphically using SQL SERVER MABAFENENT studio (SSMS) or
2. Using Query
To create the database using query
Create database "DatabaseName"
*/
Create Database My_DATABASE
/*
To Alter a database after it's ceated
alter database "Database Name" modiy name = "NewDatabase Name"
Alternative you can also use system stored procedure
Execute sp_renameDB 'OldDatabaseName','NewDatabaseName'
*/
alter database My_DATABASE modify name = new_database
/*
Alternative you can also use system stored procedure
Execute sp_renameDB 'OldDatabaseName','NewDatabaseName'
*/
Execute sp_renamedb 'My_DB','My_new_database'