欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

配置SQL Server on Linux(1)

程序员文章站 2022-04-10 12:17:29
1. 前言 SQL Server一般是在安装过程中进行相关的配置,安装完成之后,再去修改有一些配置就比较麻烦,比如更改SQL Server实例级别的排序规则。但在Linux下,安装过程并没有很多可以配置的步骤,安装步骤变得很简单,更多的配置可以通过/opt/mssql/bin/mssql-conf工 ......
1. 前言

SQL Server一般是在安装过程中进行相关的配置,安装完成之后,再去修改有一些配置就比较麻烦,比如更改SQL Server实例级别的排序规则。但在Linux下,安装过程并没有很多可以配置的步骤,安装步骤变得很简单,更多的配置可以通过/opt/mssql/bin/mssql-conf工具进行。

 

2. 环境

Linux: CentOS 7.4,SQL Server 2017 (RC2) - 14.0.900.75 (X64)

 

3. 更改SQL Server排序规则 步骤如下: 备份所有用户数据库。(如果是刚刚安装好的实例没有用户数据库可以跳过这一步。) 停止数据库实例 运行/opt/mssql/bin/mssql-conf set-collation命令修改排序规则 启动数据库实例 还原用户数据库(没有用户数据库可跳过)

 

 

下面就来演示下。

查询当前数据库实例的排序规则

1> SELECT CONVERT(NVARCHAR(50),SERVERPROPERTY('Collation'));
2> GO
                                                  
--------------------------------------------------
SQL_Latin1_General_CP1_CI_AS  

Code-1: 更改前的数据库实例排序规则

 

 

使用sp_detach_db存储过程来分离数据库。如果提示数据库正在使用,可以设置数据库为单用户模式,或者干脆就把数据库实例重启。

1> exec sp_detach_db db1;
2> go
1> exec sp_detach_db AdventureWorks2014;
2> go
1> exec sp_detach_db AdventureWorks2017;
2> go

Code-2:分离用户数据库

 

 

在shell 下:

[root@134test ~]# systemctl stop mssql-server
[root@134test ~]# /opt/mssql/bin/mssql-conf set-collation
Enter the collation: Chinese_PRC_CI_AS
Configuring SQL Server...

This is an evaluation version.  There are [27] days left in the evaluation period.
2017-12-27 10:31:21.81 Server      Microsoft SQL Server 2017 (RC2) - 14.0.900.75 (X64) 
    Jul 27 2017 08:53:49 
    Copyright (C) 2017 Microsoft Corporation
    Developer Edition (64-bit) on Linux (CentOS Linux 7 (Core))
2017-12-27 10:31:21.82 Server      UTC adjustment: 8:00
2017-12-27 10:31:21.82 Server      (c) Microsoft Corporation.
2017-12-27 10:31:21.82 Server      All rights reserved.
2017-12-27 10:31:21.82 Server      Server process ID is 4120.
2017-12-27 10:31:21.82 Server      Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'.
2017-12-27 10:31:21.83 Server      Registry startup parameters: 
     -d /var/opt/mssql/data/master.mdf
     -l /var/opt/mssql/data/mastlog.ldf
     -e /var/opt/mssql/log/errorlog
2017-12-27 10:31:21.83 Server      Command Line Startup Parameters:
     -q "Chinese_PRC_CI_AS"
2017-12-27 10:31:21.83 Server      SQL Server detected 1 sockets with 4 cores per socket and 4 logical processors per socket, 
4 total logical processors; using 4 logical processors based on SQL Server licensing. This is an informational message; no user action is required. 2017-12-27 10:31:21.84 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required. 2017-12-27 10:31:21.84 Server Detected 3027 MB of RAM. This is an informational message; no user action is required. 2017-12-27 10:31:21.84 Server Using conventional memory in the memory manager. 2017-12-27 10:31:22.36 Server Buffer pool extension is already disabled. No action is necessary. 2017-12-27 10:31:22.63 Server Perfmon counters for resource governor pools and groups failed to initialize and are disabled. 2017-12-27 10:31:22.67 Server InitializeExternalUserGroupSid failed. Implied authentication will be disabled. 2017-12-27 10:31:22.67 Server Implied authentication manager initialization failed. Implied authentication will be disabled. 2017-12-27 10:31:22.69 Server Successfully initialized the TLS configuration. Allowed TLS protocol versions are ['1.0 1.1 1.2'].
Allowed TLS ciphers are ['ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:
ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:
AES128-SHA256:AES256-SHA:AES128-SHA:!DHE-RSA-AES256-GCM-SHA384:!DHE-RSA-AES128-GCM-SHA256:!DHE-RSA-AES256-SHA:!DHE-RSA-AES128-SHA']. 2017-12-27 10:31:22.76 Server The maximum number of dedicated administrator connections for this instance is '1' 2017-12-27 10:31:22.76 Server Node configuration: node 0: CPU mask: 0x000000000000000f:0 Active CPU mask: 0x000000000000000f:0.
This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required. 2017-12-27 10:31:22.77 Server Using dynamic lock allocation. Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.
This is an informational message only. No user action is required. 2017-12-27 10:31:22.79 Server In-Memory OLTP initialized on lowend machine. 2017-12-27 10:31:22.84 Server Database Instant File Initialization: enabled. For security and performance considerations see the topic
'Database Instant File Initialization' in SQL Server Books Online. This is an informational message only. No user action is required. 2017-12-27 10:31:22.85 Server Database Mirroring Transport is disabled in the endpoint configuration. 2017-12-27 10:31:22.85 spid5s Warning ****************** 2017-12-27 10:31:22.86 spid5s SQL Server started in single-user mode. This an informational message only. No user action is required. 2017-12-27 10:31:22.86 Server Query Store settings initialized with enabled = 1, 2017-12-27 10:31:22.86 spid5s Starting up database 'master'. 2017-12-27 10:31:22.87 Server Software Usage Metrics is disabled. 2017-12-27 10:31:23.47 spid5s Buffer pool extension is already disabled. No action is necessary. 2017-12-27 10:31:23.47 spid5s SQL Server Audit is starting the audits. This is an informational message. No user action is required. 2017-12-27 10:31:23.49 spid5s SQL Server Audit has started the audits. This is an informational message. No user action is required. 2017-12-27 10:31:23.68 spid5s SQL Trace ID 1 was started by login "sa". 2017-12-27 10:31:23.68 spid5s Server name is '134test'. This is an informational message only. No user action is required. 2017-12-27 10:31:23.70 spid5s Always On Availability Groups was not started because the SQL Server instance is running in single-user mode.
This is an informational message. No user action is required. 2017-12-27 10:31:23.71 spid5s Starting up database 'msdb'. 2017-12-27 10:31:23.72 spid9s Starting up database 'mssqlsystemresource'. 2017-12-27 10:31:23.75 spid9s The resource database build version is 14.00.900. This is an informational message only. No user action is required. 2017-12-27 10:31:23.79 spid9s Starting up database 'model'. 2017-12-27 10:31:24.04 spid5s Recovery is writing a checkpoint in database 'msdb' (4). This is an informational message only. No user action is required. 2017-12-27 10:31:24.12 spid9s Polybase feature disabled. 2017-12-27 10:31:24.12 spid9s Clearing tempdb database. 2017-12-27 10:31:24.33 spid17s A self-generated certificate was successfully loaded for encryption. 2017-12-27 10:31:24.34 spid17s Server is listening on [ 'any' <ipv6> 1433]. 2017-12-27 10:31:24.35 spid17s Server is listening on [ 'any' <ipv4> 1433]. 2017-12-27 10:31:24.35 Server Server is listening on [ ::1 <ipv6> 1434]. 2017-12-27 10:31:24.36 Server Server is listening on [ 127.0.0.1 <ipv4> 1434]. 2017-12-27 10:31:24.36 Server Dedicated admin connection support was established for listening locally on port 1434. 2017-12-27 10:31:24.39 spid17s SQL Server is now ready for client connections. This is an informational message; no user action is required. 2017-12-27 10:31:24.99 spid9s Starting up database 'tempdb'. 2017-12-27 10:31:25.12 spid9s The tempdb database has 1 data file(s). 2017-12-27 10:31:25.18 spid5s Warning ****************** 2017-12-27 10:31:25.18 spid5s Attempting to change default collation to Chinese_PRC_CI_AS. 2017-12-27 10:31:25.22 spid5s index restored for master.syspriorities. 2017-12-27 10:31:25.23 spid5s index restored for master.sysbrickfiles. 2017-12-27 10:31:25.23 spid5s index restored for master.sysprufiles. 2017-12-27 10:31:25.23 spid5s index restored for master.sysowners. 2017-12-27 10:31:25.23 spid5s index restored for master.sysdbreg. 2017-12-27 10:31:25.24 spid5s index restored for master.sysschobjs. 2017-12-27 10:31:25.25 spid5s index restored for master.sysextsources. 2017-12-27 10:31:25.25 spid5s index restored for master.sysextfileformats. 2017-12-27 10:31:25.25 spid5s index restored for master.syscolpars. 2017-12-27 10:31:25.25 spid5s index restored for master.sysxlgns. 2017-12-27 10:31:25.25 spid5s index restored for master.sysxsrvs. 2017-12-27 10:31:25.26 spid5s index restored for master.sysnsobjs. 2017-12-27 10:31:25.26 spid5s index restored for master.syscerts. 2017-12-27 10:31:25.26 spid5s index restored for master.sysrmtlgns. 2017-12-27 10:31:25.26 spid5s index restored for master.sysxprops. 2017-12-27 10:31:25.26 spid5s index restored for master.sysscalartypes. 2017-12-27 10:31:25.26 spid5s index restored for master.sysidxstats. 2017-12-27 10:31:25.27 spid5s index restored for master.sysendpts. 2017-12-27 10:31:25.27 spid5s index restored for master.sysclsobjs. 2017-12-27 10:31:25.27 spid5s index restored for master.sysremsvcbinds. 2017-12-27 10:31:25.27 spid5s index restored for master.sysrts. 2017-12-27 10:31:25.27 spid5s index restored for master.sysasymkeys. 2017-12-27 10:31:25.27 spid5s index restored for master.syssqlguides. 2017-12-27 10:31:25.27 spid5s index restored for master.syssoftobjrefs. 2017-12-27 10:31:25.28 spid5s index restored for master.MSreplication_options. 2017-12-27 10:31:25.31 spid5s index restored for tempdb.syspriorities. 2017-12-27 10:31:25.32 spid5s index restored for tempdb.sysowners. 2017-12-27 10:31:25.32 spid5s index restored for tempdb.sysdbreg. 2017-12-27 10:31:25.33 spid5s index restored for tempdb.sysschobjs. 2017-12-27 10:31:25.33 spid5s index restored for tempdb.sysextsources. 2017-12-27 10:31:25.33 spid5s index restored for tempdb.sysextfileformats. 2017-12-27 10:31:25.33 spid5s index restored for tempdb.syscolpars. 2017-12-27 10:31:25.33 spid5s index restored for tempdb.sysxlgns. 2017-12-27 10:31:25.33 spid5s index restored for tempdb.sysxsrvs. 2017-12-27 10:31:25.33 spid5s index restored for tempdb.sysnsobjs. 2017-12-27 10:31:25.34 spid5s index restored for tempdb.syscerts. 2017-12-27 10:31:25.34 spid5s index restored for tempdb.sysrmtlgns. 2017-12-27 10:31:25.34 spid5s index restored for tempdb.sysxprops. 2017-12-27 10:31:25.34 spid5s index restored for tempdb.sysscalartypes. 2017-12-27 10:31:25.34 spid5s index restored for tempdb.sysidxstats. 2017-12-27 10:31:25.34 spid5s index restored for tempdb.sysendpts. 2017-12-27 10:31:25.34 spid5s index restored for tempdb.sysclsobjs. 2017-12-27 10:31:25.35 spid5s index restored for tempdb.sysremsvcbinds. 2017-12-27 10:31:25.35 spid5s index restored for tempdb.sysrts. 2017-12-27 10:31:25.35 spid5s index restored for tempdb.sysasymkeys. 2017-12-27 10:31:25.35 spid5s index restored for tempdb.syssqlguides. 2017-12-27 10:31:25.35 spid5s index restored for tempdb.syssoftobjrefs. 2017-12-27 10:31:25.39 spid5s index restored for model.syspriorities. 2017-12-27 10:31:25.40 spid5s index restored for model.sysowners. 2017-12-27 10:31:25.40 spid5s index restored for model.sysdbreg. 2017-12-27 10:31:25.42 spid5s index restored for model.sysschobjs. 2017-12-27 10:31:25.42 spid5s index restored for model.sysextsources. 2017-12-27 10:31:25.42 spid5s index restored for model.sysextfileformats. 2017-12-27 10:31:25.43 spid5s index restored for model.syscolpars. 2017-12-27 10:31:25.43 spid5s index restored for model.sysxlgns. 2017-12-27 10:31:25.44 spid5s index restored for model.sysxsrvs. 2017-12-27 10:31:25.44 spid5s index restored for model.sysnsobjs. 2017-12-27 10:31:25.44 spid5s index restored for model.syscerts. 2017-12-27 10:31:25.45 spid5s index restored for model.sysrmtlgns. 2017-12-27 10:31:25.45 spid5s index restored for model.sysxprops. 2017-12-27 10:31:25.45 spid5s index restored for model.sysscalartypes. 2017-12-27 10:31:25.46 spid5s index restored for model.sysidxstats. 2017-12-27 10:31:25.46 spid5s index restored for model.sysendpts. 2017-12-27 10:31:25.47 spid5s index restored for model.sysclsobjs. 2017-12-27 10:31:25.47 spid5s index restored for model.sysremsvcbinds. 2017-12-27 10:31:25.48 spid5s index restored for model.sysrts. 2017-12-27 10:31:25.48 spid5s index restored for model.sysasymkeys. 2017-12-27 10:31:25.48 spid5s index restored for model.syssqlguides. 2017-12-27 10:31:25.48 spid5s index restored for model.syssoftobjrefs. 2017-12-27 10:31:25.83 spid5s index restored for msdb.syspriorities. 2017-12-27 10:31:25.84 spid5s index restored for msdb.sysowners. 2017-12-27 10:31:25.84 spid5s index restored for msdb.sysdbreg. 2017-12-27 10:31:25.90 spid5s index restored for msdb.sysschobjs. 2017-12-27 10:31:25.90 spid5s index restored for msdb.sysextsources. 2017-12-27 10:31:25.90 spid5s index restored for msdb.sysextfileformats. 2017-12-27 10:31:25.96 spid5s index restored for msdb.syscolpars. 2017-12-27 10:31:25.96 spid5s index restored for msdb.sysxlgns. 2017-12-27 10:31:25.96 spid5s index restored for msdb.sysxsrvs. 2017-12-27 10:31:25.97 spid5s index restored for msdb.sysnsobjs. 2017-12-27 10:31:25.97 spid5s index restored for msdb.syscerts. 2017-12-27 10:31:25.97 spid5s index restored for msdb.sysrmtlgns. 2017-12-27 10:31:25.98 spid5s index restored for msdb.sysxprops. 2017-12-27 10:31:25.99 spid5s index restored for msdb.sysscalartypes. 2017-12-27 10:31:26.00 spid5s index restored for msdb.sysidxstats. 2017-12-27 10:31:26.00 spid5s index restored for msdb.sysendpts. 2017-12-27 10:31:26.01 spid5s index restored for msdb.sysclsobjs. 2017-12-27 10:31:26.01 spid5s index restored for msdb.sysremsvcbinds. 2017-12-27 10:31:26.02 spid5s index restored for msdb.sysrts. 2017-12-27 10:31:26.02 spid5s index restored for msdb.sysasymkeys. 2017-12-27 10:31:26.02 spid5s index restored for msdb.syssqlguides. 2017-12-27 10:31:26.04 spid5s index restored for msdb.syssoftobjrefs. 2017-12-27 10:31:26.05 spid5s index restored for msdb.syscachedcredentials. 2017-12-27 10:31:26.06 spid5s index restored for msdb.syscollector_blobs_internal. 2017-12-27 10:31:26.07 spid5s index restored for msdb.syspolicy_system_health_state_internal. 2017-12-27 10:31:26.10 spid5s index restored for msdb.sysmanagement_shared_server_groups_internal. 2017-12-27 10:31:26.11 spid5s index restored for msdb.sysssispackages. 2017-12-27 10:31:26.12 spid5s index restored for msdb.sysmanagement_shared_registered_servers_internal. 2017-12-27 10:31:26.03 spid5s index restored for msdb.sysssispackagefolders. 2017-12-27 10:31:26.04 spid5s index restored for msdb.sysutility_mi_smo_properties_to_collect_internal. 2017-12-27 10:31:26.05 spid5s index restored for msdb.syspolicy_configuration_internal. 2017-12-27 10:31:26.06 spid5s index restored for msdb.log_shipping_primary_databases. 2017-12-27 10:31:26.08 spid5s index restored for msdb.syspolicy_management_facets. 2017-12-27 10:31:26.10 spid5s index restored for msdb.syspolicy_facet_events. 2017-12-27 10:31:26.11 spid5s index restored for msdb.syscollector_config_store_internal. 2017-12-27 10:31:26.12 spid5s index restored for msdb.sysutility_ucp_dac_health_internal. 2017-12-27 10:31:26.12 spid5s index restored for msdb.sysmail_profile. 2017-12-27 10:31:26.13 spid5s index restored for msdb.MSdbms. 2017-12-27 10:31:26.14 spid5s index restored for msdb.log_shipping_primary_secondaries. 2017-12-27 10:31:26.16 spid5s index restored for msdb.syspolicy_conditions_internal. 2017-12-27 10:31:26.17 spid5s index restored for msdb.MSdbms_datatype. 2017-12-27 10:31:26.17 spid5s index restored for msdb.log_shipping_monitor_primary. 2017-12-27 10:31:26.18 spid5s index restored for msdb.log_shipping_monitor_history_detail. 2017-12-27 10:31:26.19 spid5s index restored for msdb.log_shipping_monitor_error_detail. 2017-12-27 10:31:26.19 spid5s index restored for msdb.log_shipping_secondary. 2017-12-27 10:31:26.20 spid5s index restored for msdb.log_shipping_secondary_databases. 2017-12-27 10:31:26.21 spid5s index restored for msdb.sysutility_ucp_managed_instances_internal. 2017-12-27 10:31:26.22 spid5s index restored for msdb.log_shipping_monitor_secondary. 2017-12-27 10:31:26.23 spid5s index restored for msdb.sysmail_account. 2017-12-27 10:31:26.23 spid5s index restored for msdb.sysutility_ucp_mi_health_internal. 2017-12-27 10:31:26.24 spid5s index restored for msdb.sysdac_instances_internal. 2017-12-27 10:31:26.26 spid5s index restored for msdb.syscollector_collection_sets_internal. 2017-12-27 10:31:26.27 spid5s index restored for msdb.syspolicy_policy_categories_internal. 2017-12-27 10:31:26.27 spid5s index restored for msdb.sysdac_history_internal. 2017-12-27 10:31:26.29 spid5s index restored for msdb.sysmail_servertype. 2017-12-27 10:31:26.31 spid5s index restored for msdb.syspolicy_object_sets_internal. 2017-12-27 10:31:26.32 spid5s index restored for msdb.sysutility_ucp_health_policies_internal. 2017-12-27 10:31:26.33 spid5s index restored for msdb.sysmail_server. 2017-12-27 10:31:26.33 spid5s index restored for msdb.sysutility_ucp_filegroups_with_policy_violations_internal. 2017-12-27 10:31:26.35 spid5s index restored for msdb.sysutility_ucp_policy_check_conditions_internal. 2017-12-27 10:31:26.36 spid5s index restored for msdb.syscollector_collector_types_internal. 2017-12-27 10:31:26.38 spid5s index restored for msdb.syspolicy_policies_internal. 2017-12-27 10:31:26.38 spid5s index restored for msdb.sysutility_ucp_policy_target_conditions_internal. 2017-12-27 10:31:26.39 spid5s index restored for msdb.sysmail_configuration. 2017-12-27 10:31:26.40 spid5s index restored for msdb.external_libraries_installed. 2017-12-27 10:31:26.41 spid5s index restored for msdb.sysdbmaintplan_databases. 2017-12-27 10:31:26.42 spid5s index restored for msdb.sysutility_ucp_configuration_internal. 2017-12-27 10:31:26.43 spid5s index restored for msdb.sysproxies. 2017-12-27 10:31:26.45 spid5s index restored for msdb.syssubsystems. 2017-12-27 10:31:26.46 spid5s index restored for msdb.syscollector_collection_items_internal. 2017-12-27 10:31:26.47 spid5s index restored for msdb.sysdownloadlist. 2017-12-27 10:31:26.48 spid5s index restored for msdb.sysoriginatingservers. 2017-12-27 10:31:26.50 spid5s index restored for msdb.autoadmin_managed_databases. 2017-12-27 10:31:26.51 spid5s index restored for msdb.sysjobs. 2017-12-27 10:31:26.53 spid5s index restored for msdb.smart_backup_files. 2017-12-27 10:31:26.56 spid5s index restored for msdb.backupset. 2017-12-27 10:31:26.58 spid5s index restored for msdb.sysjobsteps. 2017-12-27 10:31:26.59 spid5s index restored for msdb.syscollector_execution_stats_internal. 2017-12-27 10:31:26.59 spid5s index restored for msdb.sysutility_ucp_mi_file_space_health_internal. 2017-12-27 10:31:26.61 spid5s index restored for msdb.syspolicy_target_sets_internal. 2017-12-27 10:31:26.62 spid5s index restored for msdb.sysschedules. 2017-12-27 10:31:26.63 spid5s index restored for msdb.sysutility_ucp_mi_database_health_internal. 2017-12-27 10:31:26.64 spid5s index restored for msdb.logmarkhistory. 2017-12-27 10:31:26.64 spid5s index restored for msdb.sysutility_ucp_dac_file_space_health_internal. 2017-12-27 10:31:26.65 spid5s index restored for msdb.syscategories. 2017-12-27 10:31:26.66 spid5s index restored for msdb.systargetservers. 2017-12-27 10:31:26.67 spid5s index restored for msdb.sysutility_ucp_mi_volume_space_health_internal. 2017-12-27 10:31:26.67 spid5s index restored for msdb.sysutility_mi_dac_execution_statistics_internal. 2017-12-27 10:31:26.68 spid5s index restored for msdb.systargetservergroups. 2017-12-27 10:31:26.69 spid5s index restored for msdb.syspolicy_policy_category_subscriptions_internal. 2017-12-27 10:31:26.69 spid5s index restored for msdb.sysalerts. 2017-12-27 10:31:26.70 spid5s index restored for msdb.sysutility_ucp_computer_cpu_health_internal. 2017-12-27 10:31:26.70 spid5s index restored for msdb.sysutility_mi_session_statistics_internal. 2017-12-27 10:31:26.71 spid5s index restored for msdb.sysoperators. 2017-12-27 10:31:26.73 spid5s The default collation was successfully changed. 2017-12-27 10:31:26.73 spid5s SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required. The server collation has been changed. Please run 'sudo systemctl start mssql-server' to start SQL Server.

Code-3:更改排序规则

 

 

[root@134test ~]# systemctl start mssql-server

Code-4:重启数据库实例

 

 

查询当前数据库实例的排序规则

1> SELECT CONVERT(NVARCHAR(50),SERVERPROPERTY('Collation'));
2> GO
                                                  
--------------------------------------------------
Chinese_PRC_CI_AS

Code-5:更改后的数据库实例排序规则

 

 

还原用户数据库

1> exec sp_attach_db 'db1','/data/mssql_data/db1.mdf','/data/mssql_data/db1_log.ldf';
2> go
1> exec sp_attach_db 'AdventureWorks2014','/data/mssql_data/AdventureWorks2014.mdf','/data/mssql_data/AdventureWorks2014_log.ldf';
2> go
1> exec sp_attach_db 'AdventureWorks2017','/data/mssql_data/AdventureWorks2017.mdf','/data/mssql_data/AdventureWorks2017_log.ldf';
2> go

Code-6:还原数据库

 

 

查询当前数据库的排序规则

1> SELECT CONVERT(NVARCHAR(30),name), CONVERT(NVARCHAR(50),collation_name) FROM sys.databases;
2> GO
                                                                                 
------------------------------ --------------------------------------------------
master                         Chinese_PRC_CI_AS                                 
tempdb                         Chinese_PRC_CI_AS                                 
model                          Chinese_PRC_CI_AS                                 
msdb                           Chinese_PRC_CI_AS                                 
db1                            SQL_Latin1_General_CP1_CI_AS                      
AdventureWorks2014             SQL_Latin1_General_CP1_CI_AS                      
AdventureWorks2017             SQL_Latin1_General_CP1_CI_AS                      

(7 rows affected)

Code-7:所有数据库的排序规则

 

 

4. 参考

https://docs.microsoft.com/zh-cn/sql/linux/sql-server-linux-configure-mssql-conf

https://docs.microsoft.com/zh-cn/sql/relational-databases/system-stored-procedures/sp-detach-db-transact-sql

https://docs.microsoft.com/zh-cn/sql/relational-databases/system-stored-procedures/sp-attach-db-transact-sql