Site icon Learning & Doing

Big Query dan Cloud SQL

BigQuery

“Big Query dan Cloud SQL”

Pengantar

SQL (Bahasa Kueri Terstruktur) adalah bahasa standar untuk operasi data yang memungkinkan Anda mengajukan pertanyaan dan mendapatkan wawasan dari kumpulan data terstruktur. Ini biasanya digunakan dalam manajemen basis data dan memungkinkan Anda melakukan tugas seperti penulisan catatan transaksi ke dalam basis data relasional dan analisis data skala petabyte.

Membuat BigQuery

Uploading queryable data

Perintah SELECT, FROM, dan WHERE pada BigQuery

SELECT end_station_name FROM `bigquery-public-data.london_bicycles.cycle_hire`;
SELECT * FROM `bigquery-public-data.london_bicycles.cycle_hire` WHERE duration>=1200;

Perintah GROUP BY, COUNT, AS, dan ORDER BY

GROUP BY

SELECT start_station_name FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name;

COUNT

SELECT start_station_name, COUNT(*) FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name;

AS

SELECT start_station_name, COUNT(*) AS num_starts FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name;

ORDER BY

SELECT start_station_name, COUNT(*) AS num FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name ORDER BY start_station_name;
SELECT start_station_name, COUNT(*) AS num FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name ORDER BY num;
SELECT start_station_name, COUNT(*) AS num FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name ORDER BY num DESC;

Exporting queries as CSV files

SELECT start_station_name, COUNT(*) AS num FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY start_station_name ORDER BY num DESC;
SELECT end_station_name, COUNT(*) AS num FROM `bigquery-public-data.london_bicycles.cycle_hire` GROUP BY end_station_name ORDER BY num DESC;

Upload CSV files ke Cloud Storage

Buat Cloud SQL instance

Tambahkan Query Cloud SQL

gcloud sql connect  qwiklabs-demo --user=root
CREATE DATABASE bike;
USE bike;
CREATE TABLE london1 (start_station_name VARCHAR(255), num INT);
CREATE TABLE london2 (end_station_name VARCHAR(255), num INT);

Upload CSV files to tables

SELECT * FROM london1;
SELECT * FROM london2;

Penutup

Sahabat Blog Learning & Doing demikianlah penjelasan mengenai Big Query dan Cloud SQL. Semoga Bermanfaat . Sampai ketemu lagi di postingan berikut nya.

Exit mobile version