MS SQL 日常维护管理常用脚本(一)
SQL SERVER 数据库日常维护,管理,巡检过程中你可能经常需要用到一些SQL语句(亦或方法)来查看数据库服务器环境(操作系统版本, 磁盘空间,CPU,RAM信息),数据库信息(数据库版本,实例名称...),数据库对象等。 查看数据库信息 查看数据库服务器名称 方
SQL SERVER 数据库日常维护,管理,香港服务器租用,巡检过程中你可能经常需要用到一些SQL语句(亦或方法)来查看数据库服务器环境(操作系统版本, 磁盘空间,CPU,虚拟主机,RAM信息),数据库信息(数据库版本,实例名称...),数据库对象等。
查看数据库信息
查看数据库服务器名称
方法1:SQL脚本查询,可以通过下面脚本来查询。
默认实例
默认实例查询
命名实例
命名实例查询
方法2:在数据库实例单击右键,选择“属性”——》“常规”选项里面,香港服务器,你可以看到服务器名称(划红线部分)
方法3:都不好意思说了,你懂的。
查看数据库实例名称
方法1:去服务(services.msc)里面查找SQL Server(××××)这样的服务,有多少个就就有多少数据库实例,一般默认实例是SQL Server (MSSQLSERVER)
方法2:去SQL配置管理器的SQL Server服务配置里面找上面描述的服务。
方法3:脚本查询,只是截取数据库服务名称的实例名(其实这个还真没必要,通过上面的脚本就可查看实例,注意默认实例)
Code Snippet
下面脚本仅对命名实例有效,默认实例查询处理的是计算机名称
Code Snippet
查看数据库版本号
方法1:SQL 1:
Code Snippet
方法2:SQL 2: 看起来比较麻烦
Code Snippet
Microsoft SQL Server 2005 - 9.00.4035.00 (Intel X86) Nov 24 2008 13:01:59
Copyright (c) 1988-2005 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2)
如何从 9.00.4035.00 (Intel X86) 读取一些信息呢?
第一个数字:8 代表2000版本, 9 代表2005版本, 10 代表2008 版本
第二个数字:50 代表R2版本, 00 代表非R2版本
第三个数字:如上所示4035中第一个数字4代表打了补丁SP3,其规则如下所示
1: 代表没有打补丁
2: 代表打了SP1补丁
3: 代表打了SP2补丁,以此类推
035 : 代表相关的hotfix版本,我们在进行升级,备份,恢复一定要看清楚这个版本,只有在同一版本下的相关数据才能进行恢复(同版本备份文件),这点要注意。
方法3:在数据库实例上单击右键,选择“属性”——》“常规”选项里面,你可以看到服务器名称,平台,操作系统,数据库版本信息。
查看数据库已经打的补丁
方法1:如上所示,可以通过9.00.4035.00 (Intel X86) 来确定已经数据库已经打的最新补丁SP3。
方法2:在数据库实例上单击右键,选择“属性”——》“常规”选项里面,可以通过看到的版本信息查看补丁
方法3:在SQL配置管理器,找到相应的实例的SQL Server服务,单击右键属性.
查看实例数据库的相关信息
查看实例有哪些数据库,创建时间、排序规则.......
方法1:SQL 查询. 其实在视图sys.databases里面你可以查看很多关于数据库的信息,例如,数据库用户访问设置,数据库的状态......
SELECT * FROM sys.databases
方法2: 在Mircrosoft SQL Server Management Studio管理器里面查看。
查看排序规则信息
1:查看实例排序规则
SELECT SERVERPROPERTY(N'Collation')
2:查看数据库排序规则
SELECT name, collation_name FROM sys.databases
查询当前数据库的磁盘使用情况
如需要查询其他数据库,则需在前面指定数据库名称
EXEC sp_spaceused;
查看数据库启动相关参数
EXEC sp_configure;
查看数据库启动时间
方法1:
Code Snippet
查看所有数据库名称及大小
方法1:
EXEC sp_helpdb;
方法2:
Code Snippet
查看所有数据库用户登录信息
EXEC sp_helplogins;
查看所有数据库用户所属的角色信息
EXEC sp_helpsrvrolemember
更改某个数据对象的用户属主
sp_changeobjectowner [@objectname =] 'object', [@newowner =] 'owner'

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Cutting is a video editing tool with comprehensive editing functions, support for variable speed, various filters and beauty effects, and rich music library resources. In this software, you can edit videos directly or create editing scripts, but how to do it? In this tutorial, the editor will introduce the method of editing and making scripts. Production method: 1. Click to open the editing software on your computer, then find the "Creation Script" option and click to open. 2. In the creation script page, enter the "script title", and then enter a brief introduction to the shooting content in the outline. 3. How can I see the "Storyboard Description" option in the outline?

How to execute .sh file in Linux system? In Linux systems, a .sh file is a file called a Shell script, which is used to execute a series of commands. Executing .sh files is a very common operation. This article will introduce how to execute .sh files in Linux systems and provide specific code examples. Method 1: Use an absolute path to execute a .sh file. To execute a .sh file in a Linux system, you can use an absolute path to specify the location of the file. The following are the specific steps: Open the terminal

How to use Redis to implement distributed transaction management Introduction: With the rapid development of the Internet, the use of distributed systems is becoming more and more widespread. In distributed systems, transaction management is an important challenge. Traditional transaction management methods are difficult to implement in distributed systems and are inefficient. Using the characteristics of Redis, we can easily implement distributed transaction management and improve the performance and reliability of the system. 1. Introduction to Redis Redis is a memory-based data storage system with efficient read and write performance and rich data

We've designed this Windows PowerShell scripting tutorial for beginners, whether you're a tech enthusiast or a professional looking to improve your scripting skills. If you have no prior knowledge of PowerShell scripting, this article will start with the basics and be tailored for you. We'll help you master the installation steps for a PowerShell environment and walk you through the main concepts and features of PowerShell scripts. If you're ready to learn more about PowerShell scripting, let's embark on this exciting learning journey together! What is WindowsPowerShell? PowerShell is a hybrid command system developed by Microsoft

When we use the win10 system, when we use the mouse to right-click the desktop or the right-click menu, we find that the menu cannot be opened and we cannot use the computer normally. At this time, we need to restore the system to solve the problem. Win10 right-click menu management cannot be opened: 1. First open our control panel, and then click. 2. Then click under Security and Maintenance. 3. Click on the right to restore the system. 4. If it still cannot be used, check whether there is something wrong with the mouse itself. 5. If you are sure there is no problem with the mouse, press + and enter. 6. After the execution is completed, restart the computer.

Explore the Canvas framework: To understand what are the commonly used Canvas frameworks, specific code examples are required. Introduction: Canvas is a drawing API provided in HTML5, through which we can achieve rich graphics and animation effects. In order to improve the efficiency and convenience of drawing, many developers have developed different Canvas frameworks. This article will introduce some commonly used Canvas frameworks and provide specific code examples to help readers gain a deeper understanding of how to use these frameworks. 1. EaselJS framework Ea

The new expansion pack of "Jian Wang 3 Origin", the bloody battle, is scheduled to be released on March 21st. Two new adventures, "Liancheng Yi"/"Zhan Netherworld", will be released in early summer. A new development series of adventures will be released. Divine weapons should be given to the destined ones. Is there any chance and magic in the story? Waiting for the knight to go explore. ★New Romance Gift: Complete "City Linking"/"Slaying the Netherworld" to get the corresponding 70 Season/80 Season Sha·Da Cheng Wu. >>>In an accidental helping hand, I actually received an ordinary-looking shovel from a treasure hunting club. The handle was engraved with Zen words, hiding the wonderful principles of Buddhism... >>>Deep in the chaotic maple, mysterious ghosts disturbed the village at night. ; With a reward on the paper, in the bustling city, which hero would have the courage to reveal the reward to the people? It’s impossible to do it in daily life. You don’t have to do it in daily life. You can still enjoy it online.

Spring is an open source framework that provides many annotations to simplify and enhance Java development. This article will explain commonly used Spring annotations in detail and provide specific code examples. @Autowired: Autowired @Autowired annotation can be used to automatically wire beans in the Spring container. When we use the @Autowired annotation where dependencies are required, Spring will find matching beans in the container and automatically inject them. The sample code is as follows: @Auto
