返回首页

gbase数据、南大通用产品文档:GBase8aMINUS

更新日期:2024年09月11日

功能说明
MINUS(差运算符)返回结果集为第一个SELECT 语句的结果集,并且这个结果集
的查询结果所包含的信息不能出现在第二个查询语句结果集中。另外差运算不忽
略空值。
语法格式
select_statement1
MINUS
select_statement2
表5- 106 参数说明
参数名称


select_statement
SELECT 语句。
示例
示例1:SELECT ...MINUS SELECT...
示例中所用的表及数据:
CREATE TABLE t1 (a int , b varchar(10));
INSERT INTO t1 VALUES(1,'a'),(2,'b'),(3,'c');

GBase 8a MPP Cluster 产品手册
5 数据库管理指南
文档版本953(2022-09-15)
南大通用数据技术股份有限公司
1092
INSERT INTO t1 VALUES(null,null);
CREATE TABLE t2 (c int ,d varchar(20),e varchar(5));
INSERT INTO t2 VALUES(1,'a','aa'),(2,'b','bb'),(4,'c','cc');
MINUS
执行结果:
gbase> SELECT a,b FROM t1;
+------+------+
| a
| b
|
+------+------+
|
1 | a
|
|
2 | b
|
|
3 | c
|
| NULL | NULL |
+------+------+
4 rows in set
gbase> SELECT c AS a, d AS b FROM t2;
+------+------+
| a
| b
|
+------+------+
|
1 | a
|
|
2 | b
|
|
4 | c
|
+------+------+
3 rows in set
gbase> SELECT a ,b FROM t1 MINUS SELECT c AS a, d AS b FROM t2;
+------+------+
| a
| b
|
+------+------+
|
3 | c
|
| NULL | NULL |
+------+------+
2 rows in set

bycopy() 函数将给定的字节数从一个位置复制到另一个。

语法
void bycopy(from, to, length)
char *from;
char *to;

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 614 -
mint length;
from
指向您想要 bycopy() 复制的该组字节的第一个字节的指针。
to
指向目的字节组的第一个字节的指针。
to 指向的内存区域可与 from 参数指向的区域
交叠。在此情况下,GBase 8s ESQL/C 不保留 from 指向的值。
length
您想要 bycopy() 复制的字节数。
重要: 请注意,不要重写目标区域相邻的内存区域。

示例
此示例程序位于 demo 目录中的 bycopy.ec 文件中。
/*
* bycopy.ec *

The following program shows the results of bycopy() for three copy operations.
*/

#include

char dest[20];

main()
{
mint number1 = 12345;
mint number2 = 0;
static char string1[] = "abcdef";
static char string2[] = "abcdefghijklmn";

printf("BYCOPY Sample ESQL Program running.\n\n");

printf("String 1=%s\tString 2=%s\n", string1, string2);
printf(" Copying String 1 to destination string:\n");

GBase 8s ESQL/C 编程指南
南大通用数据技术股份有限公司
- 615 -
bycopy(string1, dest, strlen(string1));
printf(" Result = %s\n\n", dest);

printf(" Copying String 2 to destination string:\n");
bycopy(string2, dest, strlen(string2));
printf(" Result = %s\n\n", dest);

printf("Number 1=%d\tNumber 2=%d\n", number1, number2);
printf(" Copying Number 1 to Number 2:\n");
bycopy( (char *) &number1, (char *) &number2, sizeof(int));
printf(" Result = number1(hex) %08x, number2(hex) %08x\n",
number1, number2);

printf("\nBYCOPY Sample Program over.\n\n");
}
输出
BYCOPY Sample ESQL Program running.

String 1=abcdef String2=abcdefghijklmn
Copying String 1 to destination string:
Result = abcdef

Copying String 2 to destination string:
Result = abcdefghijklmn

Number 1=12345 Number2=0
Copying Number 1 to Number 2:
Result = number1(hex) 00003039, number2(hex) 00003039

BYCOPY Sample Program over.

序列是数据库对象,它生成已定义范围内的整个数字序列。数字序列可以按升序或降序运
行,并且是单调的。有关序列的更多信息,请参阅《GBase 8s SQL 指南:语法》。