SQL Server - Bài 4

45 419 0
SQL Server - Bài 4

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

SQL Server

T-SQL for Data DefinitionVu Tuyet Trinhtrinhvt-fit@mail.hut.edu.vnHanoi University of Technology1 MicrosoftMicrosoftOverview of Transact-SQLBased on AINSI SQL 92 standardComposing of three categoriesData Manipulation Language (DML)Data Definition Language (DDL)Data Control Language (DCL) Having some Microsoft specific extensionsBeyond relational data.net framework integration MicrosoftMicrosoftData Definition LanguageCreate used to create databases and their objects. Use allows you to specify the database you wish to work with within your DBMS.Alter used to modify the definition of it without deleting itDrop used to remove entire database objects MicrosoftMicrosoftOverview of Database Objects MicrosoftMicrosoftOutline√Data Definition LanguageManaging DatabasesData Types Managing Tables Managing other SQL Server Objects MicrosoftMicrosoftDatabases in SQL ServerDatabaseStoring data and other database objectsDatabase Snapshot Maintain historical data for report generationSafeguard data against administrative errorSafeguard data against user errorSQL Server Enterprise Edition MicrosoftMicrosoftCreating a New DatabaseFactors to considerDefault: Sysadmin, dbcreatorCreator becomes the ownerMaximum of 32,767 per serverFollow naming rules MicrosoftMicrosoftCreating a New DatabaseSome arguments: The name of the databaseThe size of the databaseThe files where the database will resideCREATE DATABASE SampleON PRIMARY ( NAME=SampleData, FILENAME='c:\Program Files\ \ \Data\Sample.mdf', SIZE=10MB, MAXSIZE=15MB, FILEGROWTH=20%) LOG ON ( NAME=SampleLog, FILENAME= 'c:\Program Files\ \ \Data\Sample.ldf', SIZE=3MB, MAXSIZE=5MB, FILEGROWTH=1MB)COLLATE SQL_Latin1_General_Cp1_CI_AS MicrosoftMicrosoftSetting & Viewing Database OptionsSet Database Options By Using:SQL Server Management StudioALTER DATABASE statementDatabase Option CategoriesAuto optionsCursor optionsRecovery optionsSQL optionsState options MicrosoftMicrosoftRetrieving Database InformationDetermining database properties by using the DATABASEPROPERTYEX FunctionSELECT DATABASEPROPERTYEX (‘pubs’,’useraccess’)SELECT DATABASEPROPERTYEX (‘pubs’,’recovery’)Using system stored procedures to display information about databases and its parameterssp_helpdbsp_helpdb database_namesp_spaceused [objname] [...]... Data-level consistency • Complex application development & deployment • Integration with structured data • Complex application development & deployment • Separate data management • Enterprise-scales only • Poor data streaming support • File size limitations • Highest cost per GB • Windows File Servers • NetApp NetFiler • EMC Centera • Fujitsu Nearline • SQL Server VARBINARY(MAX) BLOB Storage in SQL Server. .. File System Application TSQL (Same as SQL BLOB)  Win32 Streaming APIs with T -SQL transactional semantics    BLOB Data Consistency Integrated Manageability Back Up / Restore  Administration    Size limit is the file system volume size SQL Server Security Stack Microsoft DB BLOB Storage Vision File Stores / BLOB Stores Streaming Performance Depends on external store SQL BLOBs Remote BLOB Store... & Time   bit, tinyint, smallint, int, bigint, numeric, decimal, smallmoney, money binary, varbinary, image Others  Microsoft sql_ variant, timestamp, xml… User-defined Data Type  Extending the SQL type system as   Microsoft alias data types that consist of a single SQL Server system data type or structure of multiple data types having behaviors (CLR Type) New Date & Time Data Types  DATE   TIME... a Database   SQL Server Enterprise Manager DROP DATABASE statement DROP DATABASE Northwind, pubs  Restrictions on Dropping a Database     Microsoft While it is being restored When a user is connected to it When publishing as part of replication If it is a system database Outline √ √    Data Definition Language Managing Databases Data Types Managing Tables Managing other SQL Server Objects... on external store SQL BLOBs Remote BLOB Store API FILESTREAM Depends on external store Link Level Consistency Data Level Consistency Integrated Management Non-local Windows File Servers Interop with External BLOB Stores Microsoft n/a n/a Post-2008 ... supports operations      Microsoft Query() – returns XML from XQuery expression Value() – returns SQL type from XQuery Exist() – bool if XQuery exists Modify() – changes XML using XQuery Nodes() – shreds XML into relational data; think of it as a table valued split Storing Document & Multimedia Use File Servers Dedicated BLOB Store Store BLOBs in Database Application Application Application BLOBs BLOBs... NetFiler • EMC Centera • Fujitsu Nearline • SQL Server VARBINARY(MAX) BLOB Storage in SQL Server Use File Servers Application BLOB Store BLOBs in Database DB Application Dedicated BLOB Store Store BLOBs in DB + File System Application BLOB BLOB Application BLOB DB DB DB Remote BLOB Storage Microsoft SQL BLOB FILESTREAM Storage FILESTREAM Data Type    Storage Attribute on VARBINARY(MAX) Unstructured... IsDescendant Parse GetDescendant GetLevel Reparent Tostring Spatial Data Types   Storing geographic locations and shapes such as landmarks, roads, building, … Based on vector model specified in Well-Known Text (WKT) or WellKnown Binary (WKB) format (recommended by Open Geospatial Consortium) Microsoft Geography & Geometry Data Type Microsoft Performing Spatial Operations  Both types provide static...  Automatic validation of XML documents  Automatic shredding of the XML data to support efficient querying and updating of the content  Searching and updating via an implementation of XQuery and XML-DML Microsoft Using XML Data Type  Declaration is (mostly) like other data types    Usage is (mostly) like other data types    Table: CREATE TABLE T(MyXml XML) Variable: DECLARE @MyXml XML Query:... Some of the limitations:     Microsoft Does not support converting to text or ntext Cannot be compared or sorted So, no GROUP BY, PRIMARY KEY, etc Cannot be used as a parameter to any scalar, built-in functions other than ISNULL, COALESCE, and DATALENGTH Stored semantically The order of attributes and insignificant white spaces are not preserved Creating XML Data  Converting Strings    Bulk . T -SQL for Data DefinitionVu Tuyet Trinhtrinhvt-fit@mail.hut.edu.vnHanoi University of Technology1 MicrosoftMicrosoftOverview of Transact -SQL Based. DatabasesData Types Managing Tables Managing other SQL Server Objects MicrosoftMicrosoftDatabases in SQL Server DatabaseStoring data and other database objectsDatabase

Ngày đăng: 15/11/2012, 10:59

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan