SQL语句笔记之Teradata

参考来源:

http://www.info.teradata.com/htmlpubs/db_ttu_13_10/index.html#page/SQL_Reference/B035_1
146_109A/ch01.3.095.html

http://www.teradatawiki.net/2013/10/Teradata-SAMPLE-Function.html

 

1.熟悉数据库中的数据 

/*
You use different commands to do this in Teradata than
you use in MySQL. Instead of using SHOW or DESCRIBE to get a list of columns in a table,use:
*/

HELP TABLE [name of table goes here; don’t include the
brackets when executing the query]
/*
To get information about a single column in a table, you could write:
*/
HELP COLUMN [name of column goes here; don’t include the
brackets when executing the query]
/*
One thing that is missing from the information outputted by HELP is whether or not a
column is a primary or foreign key. In order to get that information, use a SHOW command:
*/
SHOW table [insert name of table here; don’t include the
brackets when executing the query];

2. TOP用法代替MYSQL中的LIMIT

/*
The following statement
would select the first 10 rows of the strinfo table as they are stored in the native database:
*/
SELECT TOP 10 *
FROM strinfo
/***************升序***************/
SELECT TOP 10 *
FROM strinfo
ORDER BY city ASC
/**************降序****************/
SELECT TOP 10 *
FROM strinfo
ORDER BY city DESC

3. SMAPLE用法

/*
In
addition, there is a function available in Teradata (but not MySQL) called SAMPLE that allows
you to select a random sampling of the data in a table:
*/
/*
The following query would retrieve 10 random rows from the strinfo table:
*/
SELECT *
FROM strinfo
SAMPLE 10
/*
The following query would retrieve a random 10% of the rows from the strinfo table:
*/
SELECT *
FROM strinfo
SAMPLE .10

3.MYSQL和Teradata之间的不同 。

/*
1. DISTINCT and LIMIT can be used in the same query statement in MySQL, but
DISTINCT and TOP cannot be used together in Teradata
2. MySQL accepts either double or single quotation marks around strings of text in queries,
but Teradata will only accept single quotation marks
3. MySQL will accept the symbols “!=” and “<>” to indicate “does not equal” but Teradata
will only accept “<>” (other operators, like “IN”, “BETWEEN”, and “LIKE” are the
same: http://www.teradatawiki.net/2013/09/Teradata-Operators.html)
*/

 

转载于:https://www.cnblogs.com/Shinered/p/9505539.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值