从 Microsoft 课程(由第三方提供)中,我了解到当表具有聚集索引时,即使是非聚集索引也会命中聚集索引。
当我理解没有聚集索引(堆)时,非聚集索引直接引用到表的页面中。
假设正确理解,为什么非聚集索引会引用聚集索引而不是直接引用表的底层数据页?似乎直接引用表数据页的开销会更少。
我尝试从 SQL Server 2012 (11.0.5058) 添加在 SQL Server 2008 R2 (10.50.4000) 上运行的链接服务器。
我不断收到此错误:
链接服务器已创建,但连接测试失败。您想保留链接服务器吗?

有谁知道如何解决这个问题?
不同版本数据库之间搭建链接服务器有没有限制?
好的,使用 tsql 代码创建了这个链接服务器
EXEC sp_addlinkedserver
@server='xxxLinkedServer', -- here you can specify the name of the linked server
@srvproduct='',
@provider='sqlncli', -- using SQL Server Native Client
@datasrc='xxxxxx', -- add here your server name
@location='',
@provstr='',
@catalog='smpro5' -- add here your database name as initial catalog (you cannot connect to the master database)
-- Add credentials and options to this linked server
EXEC sp_addlinkedsrvlogin
@rmtsrvname = …Run Code Online (Sandbox Code Playgroud) 我有一个表由以下字段组成
id, name
Run Code Online (Sandbox Code Playgroud)
具有以下值
1, ciro
2, test ciro
3, ciprox
4, other
5, other
Run Code Online (Sandbox Code Playgroud)
我想获得所有以“ci”开头或包含“ci”的值,但在它们以ci开头然后其余部分之前向我显示结果。
查询
select * FROM table WHERE name like 'ci%' or name like '%ci%' order by name;
Run Code Online (Sandbox Code Playgroud)
我回来了
1, ciro
2, test ciro
3, ciprox
Run Code Online (Sandbox Code Playgroud)
我想要
1, ciro
3, ciprox
2, test ciro
Run Code Online (Sandbox Code Playgroud)
因此在名称以“ci”开头的行之前,然后是那些包含
有没有办法不使用两个查询来获得结果?
我使用Mamp Pro 3。我使用此脚本https://gist.github.com/tobi-pb/b9426db51f262d88515c将Mamp的MySql升级到5.6.24。
之后我运行了 Mamp Pro 并且 MySql 无法启动。于是我查看了mysql_error.log,发现如下错误:
2015-06-15 01:24:55 13139 [ERROR] /Applications/MAMP/Library/bin/mysqld: unknown variable 'table_cache=64'
2015-06-15 01:24:55 13139 [ERROR] Aborting
Run Code Online (Sandbox Code Playgroud)
在我用谷歌搜索这个错误之后,我知道我必须从(MySql 配置)文件中删除 ' table_cache=64 ' 变量my.cnf。所以我从/Applications/MAMP/tmp/mysql/my.cnf文件中删除了这个变量。
但是问题是再次启动MySql时,还是出现同样的错误。于是我查看了my.cnf文件,' table_cache=64 ' 又自动重新出现了。我再次删除了它,但是当我启动 MySql 时它又自动出现了。
我应该如何解决这个“ table_cache=64 ”问题?
我有一个数据库用户——比如说“x”——我想知道有多少 Windows(桌面)用户正在使用这个数据库用户(who2 或 who 只给出当前结果,我想知道整个历史) ?
实际上,当您加入任何新组织并且您不知道有多少 Windows 或桌面用户在使用特定数据库用户时,就会出现这个问题。有没有办法知道这一点?您如何跟踪使用此 (x) 用户凭据的所有 Windows 用户?
我所听到的一切(包括来自微软)都说你永远不应该缩小数据库。然而,一家软件供应商 (Symantec) 告诉我们对DBCC SHRINKFILESQL 2012 数据库和与其名为 Enterprise Vault 的产品相关的日志进行处理。
我是否应该遵循赛门铁克的建议,shrink或者微软和其他所有人的建议不要收缩?
我想知道是否可以直接在 MySQL SELECT 中转换符号序列中的数字返回(INT 列)。
我的表如下:
| ID | category |
|-----------|----------|
| product_1 | 5 |
| product_2 | 4 |
| product_3 | 3 |
Run Code Online (Sandbox Code Playgroud)
我想要一个像SELECT ID, some_mysql_fancy_func(category,'*') AS symbol_category FROM MyTable这样的 SQL SELECT可以返回以下内容:
| ID | symbol_category |
|-----------|-----------------|
| product_1 | ***** |
| product_2 | **** |
| product_3 | *** |
Run Code Online (Sandbox Code Playgroud)
是否可以?
我可以以编程方式完成,但这不是我的意图,我想要一些内置(甚至自定义)函数可以直接在 SELECT 语句中实现此结果。
我希望修复 Oracle 中的数据表,理想情况下是通过非特权 SQL,该 SQL 已将 UTF-8 数据插入到 UTF-8 数据库中,错误地使用了 Latin-1 字符集。
该符号? GREEK SMALL LETTER BETA应该已进入数据库,但两个字符β已进入......因为两个 UTF-8 字符
Î LATIN CAPITAL LETTER I WITH CIRCUMFLEX后跟² SUPERSCRIPT TWO.
此示例代码演示了问题和修复方法,但它仅适用于VARCHAR列。一旦CLOB使用了a ,转换就会失败:
-- This must return AL32UTF8 for this example to be valid
SELECT VALUE FROM NLS_DATABASE_PARAMETERS WHERE PARAMETER='NLS_CHARACTERSET';
CREATE TABLE EXAMPLE (T VARCHAR2(20));
INSERT INTO EXAMPLE (T) VALUES ('Example β');
SELECT T FROM EXAMPLE; -- Should return 'Example β'
SELECT …Run Code Online (Sandbox Code Playgroud) 我有一个包含 col1、col2、col3 列的简单表格。都不可为空。
我想删除元组 (col1, col2) 有多个条目的所有行。背景:应添加 (col1, col2) 的唯一约束。
drop table mytable;
create table mytable (
col1 integer not null,
col2 integer not null,
col3 integer not null);
-- rows to delete
insert into mytable values (1, 1, 1);
insert into mytable values (1, 1, 2);
-- rows to keep
insert into mytable values (2, 2, 1);
insert into mytable values (2, 3, 2);
delete from mytable where
(col1, col2) in (
select col1, col2 from mytable
group by …Run Code Online (Sandbox Code Playgroud) 我在 /usr/bin 下找不到 pg_resetxlog。
postgres (PostgreSQL) 10.7 (Ubuntu 10.7-1.pgdg16.04+1)
cd /usr/bin
postgres@node-1:/usr/bin$ ./pg_resetxlog
-su: ./pg_resetxlog: No such file or directory
Run Code Online (Sandbox Code Playgroud)