Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
beliveinmyshelf
Starting Member
15 Posts |
Posted - 2007-05-28 : 00:33:08
|
i'm learning SQL server in APTECH. it's difficult. i use "book online" to look up the syntax, code example.....and i have a code as follow :use mastergocreate database ex1on( name=ex1_file, filename='C:\ex1_file.mdf', size=10,maxsize=10,filegrowth=10)log on( name=ex1_log filename='C:\ex1_log.ldf', size=5,maxsize=5,filegrowth=10)gobut i don't know this section in above code :USE MASTEGOplease explain for methank very much |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-05-28 : 00:34:34
|
It means make Master database as my current database, henceforth.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-05-28 : 02:26:56
|
in other words, it means the CREATE DATABASE statement is executed in the context of the master database. www.elsasoft.org |
 |
|
beliveinmyshelf
Starting Member
15 Posts |
Posted - 2007-05-28 : 02:43:11
|
but ex1 database is equivalent with master database because they are database together.why use its in above code :USE MASTERGO |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-28 : 02:54:07
|
quote: but ex1 database is equivalent with master database because they are database together
What do you mean by this ?The script you posted basically is for creating a new database named ex1. Before creating the new database ex1, it set the current database context to master. KH |
 |
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-05-28 : 02:55:56
|
maybe this example will help. this creates a new database called foo, switches to the context of foo, then creates a table called bar. bar is created in foo because it's executed in the context of foo.use mastergocreate database foogouse foogocreate table bar(id int)go here's a similar one, but bar is created in the master database (oops!) because the "use foo" statement is missing:use mastergocreate database foogocreate table bar(id int)go www.elsasoft.org |
 |
|
beliveinmyshelf
Starting Member
15 Posts |
Posted - 2007-05-28 : 03:24:31
|
thank very much.it's meaningmy database (ex1) isn't relate with master database.formerly, i thought they have a relation. it's crazy.thank very much |
 |
|
|
|
|
|
|