Filegroups are named collections of files, and are used to simplify data placement
Estimating the size of a database
CREATE DATABASE database_name [ ON [ PRIMARY ] [ filespec [, n] ] [ FILEGROUP filegroup_name [DEFAULT] ] filespec [, n] ] [, n] ] [ LOG ON [filespec [, n] ] [ COLLATE collation_name ]
DB정보 보기
EXEC sp_helpdb database_name
ALTER DATABASE database_name MODIFY FILE ( NAME = logical_file_name, SIZE = size [ KB | MB | GB | TB ] )
DBCC SHRINKFILE ( { 'file_name' | file_id } { [ ,EMPTYFILE ] | [ [ , target_size ] [ , { NOTRUNCATE | TRUNCATEONLY } ] ] } )
A schema is a namespace for database objects.
Every database contains a schema called dbo. The dbo schema is the default schema for all users who do not have an explicitly defined default schema.
CREATE SCHEMA schema_name | AUTHORIZATION owner_name | schema_name AUTHORIZATION owner_name [ table_definition | view_definition | grant_statement | revoke_statement | deny_statement ]
스키마 정보 보기
1) SELECT * FROM SYS.SCHEMAS 2) SELECT DISTINCT TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES 3) SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS
SQL Server 2005 uses the following process to resolve an unqualified object name:
Set database options by using:
^ Option ^ Category Purpose ^
Automatic | Controls automatic behaviors such as statistics, database closing, and shrinking |
---|---|
Availability | Controls whether database is online, who can connect to it, and whether database is read-only |
Cursor | Controls cursor bahavior and scope |
Recovery | Controls the recovery model for the database |
SQL | Controls ANSI compliance options such as ANSI nulls and recursive triggers |
싱글유저 모드로 전환하기 (OFFLINE을 하기전에 실행한다. 이 작업을 수행하지 않으면 OFFLINE이 무척이나 오래걸리게 된다.)
ALTER DATABASE Sample SET SINGLE_USER WITH ROLLBACK AFTER 60;
Information Source | Description |
---|---|
SQL Server Management Studio | Visual tool that generates reports displaying server and database metadata |
Catalog views | Provide metadata about database objects returning rows of information |
Metadata functions | Return a single value of metadata information per function |
System stored procedures | Retrieve metadata using stored procedures |