Results 1 to 4 of 4

Thread: Create Database

  1. #1
    Join Date
    Jun 2010
    Posts
    28

    Unanswered: Create Database

    Hi All

    Just wondering what the difference between the 3 name we specify are when creating a database e.g.

    Code:
    create database test_db on primary
    (
       name = 'test_db_dat',
       filename = '...\...\...\test_db_dat.mdf'
       ....
    )
    So there are 3 example above in red where we specify the database name. From my understanding the first name we specify 'test_db' is for the benefit of SQL Server Management Studio Object Explorer. The second 'test_db_dat' is what i am confused about and the third '...\...\...\test_db_dat.mdf' is the physical file location and name.

    Am I right in the above? Can some explain the difference?

    Many Thanks

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    The database name (test_db) is the name by which SQL Server knows the database. With the exception of SQL to Operating System issues, this is the only name that SQL Server uses for this database.

    The filename is exactly as you've described it... It is the name of the physical file being created or managed.

    In the days of dragons (circa 1990) there was a plan to establish SQL Server as a full-blown operating system in its own right, as well as running on other operating systems (like Linux, OS/2, and NetWare). This name associated with SQL Server files allowed the SQL Server developers to neatly sidestep all of the gory details of the underlying file system by creating a name for the file that was independent of the underlying Operating System (or lack thereof). It remains a convenient way to dodge a lot of otherwise hard to avoid problems, so the structure lives on and does provide some useful abstraction under the covers.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Jun 2010
    Posts
    28
    Quote Originally Posted by Pat Phelan View Post
    The database name (test_db) is the name by which SQL Server knows the database. With the exception of SQL to Operating System issues, this is the only name that SQL Server uses for this database.

    The filename is exactly as you've described it... It is the name of the physical file being created or managed.

    In the days of dragons (circa 1990) there was a plan to establish SQL Server as a full-blown operating system in its own right, as well as running on other operating systems (like Linux, OS/2, and NetWare). This name associated with SQL Server files allowed the SQL Server developers to neatly sidestep all of the gory details of the underlying file system by creating a name for the file that was independent of the underlying Operating System (or lack thereof). It remains a convenient way to dodge a lot of otherwise hard to avoid problems, so the structure lives on and does provide some useful abstraction under the covers.

    -PatP
    Perfect - thanks Pat!

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Next up on The History Channel....
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •