小编Eme*_*ski的帖子

将 CSV 从 Google Storage 导入 Google SQL 时,是否可以跳过第一行?

https://console.cloud.google.com/sql/instances/选择一个实例,然后选择“导入”,然后选择“CSV”。

我没有看到任何跳过第一行的选项。

LOAD 语句可以做到,我只是在 Web UI 中没有看到该选项。

google-cloud-storage google-cloud-sql

5
推荐指数
1
解决办法
690
查看次数

Postgres ANY运算符,在子查询中选择了数组

有人可以向我解释为什么第四个选择有效,但是前三个不起作用吗?(如果重要的话,我使用的是PostgreSQL 9.3.4。)

drop table if exists temp_a;
create temp table temp_a as
(
    select array[10,20] as arr
);

select 10 = any(select arr from temp_a);    -- ERROR:  operator does not exist: integer = integer[]

select 10 = any(select arr::integer[] from temp_a); -- ERROR:  operator does not exist: integer = integer[]

select 10 = any((select arr from temp_a));  -- ERROR:  operator does not exist: integer = integer[]

select 10 = any((select arr from temp_a)::integer[]);   -- works
Run Code Online (Sandbox Code Playgroud)

这是一个sqlfiddle:http ://sqlfiddle.com/#!15/56a09/2

postgresql

4
推荐指数
1
解决办法
3934
查看次数

4
推荐指数
1
解决办法
844
查看次数

Postgres未分配的记录,有没有一种方法可以测试null?

有什么方法可以测试未分配的记录是否为空?(对不起,sqlfiddle不喜欢我的DO块。)谢谢。

DO
$$
DECLARE
r record;
BEGIN

r := null;

if r is null    -- ERROR:  record "r" is not assigned yet
then
end if;

END
$$;
Run Code Online (Sandbox Code Playgroud)

postgresql postgresql-9.3 sql-null

3
推荐指数
1
解决办法
2732
查看次数

Google BigQuery似乎运行在太平洋时区而不是UTC.这有什么好的理由吗?有没有办法改变它?

UDF:

bigquery.defineFunction(
  'newdate',                           // Name of the function exported to SQL
  [],                    // Names of input columns
  [
    {name: 'date', type: 'timestamp'}
    , {name: 'datestr', type: 'string'}
  ],
  function newDate(row, emit) {
    var date = new Date();  // current date and time

    emit({
      date: date
      , datestr: date + ''
    });
  }
);
Run Code Online (Sandbox Code Playgroud)

SQL:

SELECT date, datestr
FROM (newDate(SELECT "ignored" AS inputA))
Run Code Online (Sandbox Code Playgroud)

输出:

1459282876835809    Tue Mar 29 2016 13:21:16 GMT-0700 (PDT)  
Run Code Online (Sandbox Code Playgroud)

google-bigquery

3
推荐指数
1
解决办法
248
查看次数