SQL Server 可以在实例,数据库,列,查询分别指定排序规则

/*
Module 1 - working with Clollations
*/
-- 1.1 Obtain the Instance Collation from the GUI
--Create a Database without specifying a specific Collation
Create Database UnspecifiedCollationDB;
GO -- Use the statement bellow(code) to verfiy that the new database inherited the Collation
USE UnspecifiedCollationDB;
GO Select DB_NAME() as Current_Database, DATABASEPROPERTYEX('UnspecifiedCollationDB','Collation') DatabseCollation -- 1.2 Create a Database with a Collation that overrides the Instance Default Collation
Create Database MultiLingualSpeakDB
Collate Arabic_CI_AI
--Use The GUI to obtain the collation of the new database. -- 1.3 Create Text-base Columns Within a Table with Collations that overide the Database
USE MultiLingualSpeakDB
Create Table MixedSpeakTable
(
ProductDI int IDENTITY
,EnglighProdName nvarchar(30) COLLATE Latin1_General_CI_AI NOT NULL
,ArabicProdName nvarchar(30) NOT NULL
,GreeekProdName nvarchar(30) COLLATE Greek_CS_AS_KS NOT NULL
,JapaneseProdName nvarchar(30) COLLATE Japanese_90_CI_AS_KS_WS NOT NULL
);
--Use the GUI o drill down to the new table, then to one the columns and obtain
--column Collation settting. -- 1.4 Open a new query window to the tempDB database USE tempdb
GO
--Retrieve and discuss the collation of the system and tempdb
Select SERVERPROPERTY('Collation') as SystemCollation,
DATABASEPROPERTYEX('tempdb','Collation') as DatabaseCollation;
GO -- Create and populate a table with different column collations
Create Table dbo.TestCharacter
(
id int IDENTITY,
CIData varchar(10) COLLATE Latin1_General_CI_AS,
CSData varchar(10) COLLATE Latin1_General_CS_AS
) INSERT INTO dbo.TestCharacter(CIData,CSData)
VALUES ('Test Data','Test Data');
GO -- Execute queries that try to match the same
-- values from eache column with all lower case
SELECT * FROM dbo.TestCharacter
WHERE CIData='test data';
-- Now query the case-sensitive column
SELECT * FROM dbo.TestCharacter
WHERE CSData='test data'; -- No rows retruned
GO --Execute a query to perform a case-insensitive
--search on the case-sensitive data
SELECT * FROM dbo.TestCharacter
WHERE CSData='test data' COLLATE Latin1_General_CI_AS; -- Try to execute a query that compares the two columns
-- that have different collations. this will fail
-- as the collation conflict cannot be resolved
SELECT * FROM dbo.TestCharacter
WHERE CIData=CSData;
-- Execute the qery while specifying a collation
SELECT * FROM dbo.TestCharacter
WHERE CIData=CSData COLLATE Latin1_General_CI_AS;

合理分配文件组提升数据库性能

/*
Module 1 Create a Database with Advanced Design; Multiple Data and Multiple Filegroups
*/ --Enable xp_CMDSHELL to run operating system commands with T-SQL code. EXEC master.dbo.sp_configure 'Show Advanced Options',1;
RECONFIGURE;
EXEC master.dbo.sp_configure 'xp_CmdShell',1;
RECONFIGURE;
----------------- -- Make "Drive Latters" to simulate existence of may drive letters(LUNs)
-- for the advanced database.
USE master
Go
EXEC XP_CMDSHELL 'MD c:\Drive_D', no_output
EXEC XP_CMDSHELL 'MD c:\Drive_E', no_output
EXEC XP_CMDSHELL 'MD c:\Drive_F', no_output
EXEC XP_CMDSHELL 'MD c:\Drive_G', no_output
EXEC XP_CMDSHELL 'MD c:\Drive_H', no_output
EXEC XP_CMDSHELL 'MD c:\Drive_I', no_output
EXEC XP_CMDSHELL 'MD c:\Backups', no_output
GO -- 2.1 Create the AdvancedDB
CREATE DATABASE AdvancedDB
/* Scripte assumes the existence of c:\Drive_D etc,
to SIMULATE multipledisk drives.
*/
ON Primary
-- NOTICE below non-uniform SIZE, MAXSIZE,and FILEGROUP parmerters!
(
Name=AdvancedDBF1_PrimaryFG
,Filename='c:\Drive_D\AdvancedDB_F1_PrimaryFG.MDF'
,Size=16MB
,MaxSize=30
,FileGrowth=10%
)
,FILEGROUP CurrentDataFG
(
Name=AdvancedDBF1_CurrentDataFG
,Filename='c:\Drive_E\AdvancedDB_F1_CDFG.ndf'
,Size=6MB
,MaxSize=15
,FileGrowth=10%
)
,(
Name=AdvancedDBF2_CurrentDataFG
,Filename='c:\Drive_E\AdvancedDB_F2_CDFG.ndf'
,Size=6MB
,MaxSize=15
,FileGrowth=10%
)
,FILEGROUP ArchiveDataFG
(
Name=AdvancedDBF1_ArchiveDataFG
,Filename='c:\Drive_F\AdvancedDB_F1_AFG.ndf'
,Size=6MB
,MaxSize=15
,FileGrowth=10%
)
,(
Name=AdvancedDBF2_ArchiveDataFG
,Filename='c:\Drive_G\AdvancedDB_F2_AFG.ndf'
,Size=6MB
,MaxSize=15
,FileGrowth=10%
)
LOG ON
(
Name=AdvancedDBLogF1
,Filename='c:\Drive_G\AdvancedDB_LogF1.ldf'
,Size=6MB
,MaxSize=15
,FileGrowth=10%
)
; --Create a Table (space-occupying-object) withut specifying a FileGroup
USE AdvancedDB;
GO Create TABLE dbo.tb1_Table1
(
COl1 nvarchar(20)
)
Create TABLE dbo.tb1_Table2
(
COl1 nvarchar(20)
)
ON ArchiveDataFG
-- Use the GUI to show the FileGroups and Files of AdvancedDB
-- Use the GUI to show the two tables one being on the default FG
-- and the other table being on a designated FG.

Microsoft SQL Server 2012 管理 (1): 安装配置SQL Server 重点的更多相关文章

  1. Sql Server 2012数据库的安装【自己一点一点敲的】

    Sql Server 2012数据库的安装 1.到微软官网上下载 下载链接为:https://www.microsoft.com/zh-cn/download/details.aspx?id=2906 ...

  2. Windows Server 2012 R2在线安装.NET Framework3.5

    Windows Server 2012 (R2) 默认没有安装 .NET Framework 3.5,但可以通过在线安装或指定备用源路径方式. 之前在这个 在Win Server 2012中安装.NE ...

  3. Windows server 2012 R2下安装sharepoint2013

    • 安装windows server 2012 R2 系统,配置IP.系统打补丁,修改主机名.加域后重启.• 安装WEB服务器,勾选windows身份验证 • 安装应用程序服务器 • 安装.NET F ...

  4. windows server 2012 R2里IIS配置.net core2.1遇到的坑

    首先刚接触.net core不久,在本地也是简单写点测试程序,没遇到过什么问题,感觉还行,最近朋友搞了个asp.net core2.1的程序,让我给他服务器配置一下,我想这都跨平台了有什么难的吗?拿来 ...

  5. 解决Win8.1 / Win Server 2012 r2 下安装 Visual Studio 时一直要求重新启动的问题(原创)

    注:本文为作者原创文章,转载于引用请注明出处,谢谢. 今天在x64的英文版Windows Server 2012 r2上安装最新版的 Visual Studio 2015 Exterprise 时,提 ...

  6. 在Windows Server 2012服务器上安装可靠多播协议

    为什么要安装可靠多播协议?   答:随着因特网的发展,出现了视频点播.电视会议.远程学习.计算机协同工作等新业务.传统的点到点通信方式,不仅浪费大量的网络带宽,而且效率很低.一种有效利用现有带宽的技术 ...

  7. Windows Server 2012 R2上安装.Net4.6.1出错

    在Windows Server 2012 R2上安装.Net4.6.1时提示“你需要先安装对应于 KB2919355 的更新,然后才可在……”解决方式: 在官网下载更新包,下载地址:https://w ...

  8. PL/SQL Developer 和 instantclient客户端安装配置

    PL/SQL Developer 和 instantclient客户端安装配置 oracle的安装我就不写了,不会安装的网上随便找一个教程就能装上,安装起来比較简单.可是,PL/SQL Develop ...

  9. L/SQL Developer 和 instantclient客户端安装配置

    PL/SQL Developer 和 instantclient客户端安装配置(图文) 一: PL/SQL Developer 安装 下载安装文件安装,我这里的版本号是PLSQL7.1.4.1391, ...

随机推荐

  1. 第五章 二叉树(e2)中序遍历

  2. Top K算法

    应用场景: 搜索引擎会通过日志文件把用户每次检索使用的所有检索串都记录下来,每个查询串的长度为1-255字节.        假设目前有一千万个记录(这些查询串的重复度比较高,虽然总数是1千万,但如果 ...

  3. OpenStack概念架构简述

    什么是OpenStack OpenStack既是一个社区,也是一个项目和一个开源软件,它提供了一个部署云的操作平台或工具集.其宗旨在于,帮助组织运行为虚拟计算或存储服务的云,为公有云.私有云,也为大云 ...

  4. mybatis框架的架构(图解)

    1. mybatis配置 SqlMapConfig.xml,此文件作为mybatis的全局配置文件,配置了mybatis的运行环境等信息. mapper.xml文件即sql映射文件,文件中配置了操作数 ...

  5. How to set an Apache Kafka multi node – multi broker cluster【z】

    Set a multi node Apache ZooKeeper cluster On every node of the cluster add the following lines to th ...

  6. Django之Form功能

    一 什么是Form?什么是DjangoForm? Django表单系统中,所有的表单类都作为django.forms.Form的子类创建,包括ModelForm 关于django的表单系统,主要分两种 ...

  7. spring boot2.03 spring cloud Finchley.RELEASE遇到的问题

    1.spring cloud bus 本地不能更新 原因是@RefreshScope注解要加在需要更新的controller上 2.No instances found of configserver ...

  8. 面向对象设计模式纵横谈:Prototype 原型模式(笔记记录)

       有一段时间没写东西了,今天继续把没写完的设计模式写完,今天这堂课是创建型设计模式的最后一堂课,原型设计模式,它同样也是解决了对象在创建的过程中的解耦合的情况,面对变化使代码更稳定,更准确的说是使 ...

  9. OpenGLES.APPLE_texture_format_BGRA8888

    OpenGL ES的扩展: APPLE_texture_format_BGRA8888 http://www.khronos.org/registry/gles/extensions/APPLE/AP ...

  10. Rendering Resources

    1. Real-Time Rendering Resources http://www.realtimerendering.com/ 2. Books on Amazon http://www.ama ...