从https://console.cloud.google.com/sql/instances/选择一个实例,然后选择“导入”,然后选择“CSV”。
我没有看到任何跳过第一行的选项。
LOAD 语句可以做到,我只是在 Web UI 中没有看到该选项。
有人可以向我解释为什么第四个选择有效,但是前三个不起作用吗?(如果重要的话,我使用的是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
我只想查看CSV文件的列标题,因此可以在将表导入Cloud SQL之前创建表。最好在https://console.cloud.google.com/storage/browser上使用基于Web的存储浏览器
有什么方法可以测试未分配的记录是否为空?(对不起,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) 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)