Skip to content

Instantly share code, notes, and snippets.

-- ----------------------------
-- Table structure for member
-- ----------------------------
DROP TABLE IF EXISTS "public"."member";
CREATE TABLE "public"."member" (
"id" int4 NOT NULL,
"no_urut" int4,
"parent_id" int4,
"name" varchar(255) COLLATE "pg_catalog"."default"
)
@hidayat365
hidayat365 / code.html
Created July 8, 2021 10:48
Code in HTML
<div class="tab-content" id="curl" style="display: block;">
<div class="tab-content-button">
<button id="copy-curl" style="font-size: 12px">
<svg aria-hidden="true" class="svg-inline--fa fa-copy fa-w-14" data-fa-i2svg="" data-icon="copy" data-prefix="fas" focusable="false" role="img" viewbox="0 0 448 512" xmlns="http://www.w3.org/2000/svg">
<path d="M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z" fill="currentColor"></path>
</svg>
</button>
</div>
<div class="tab-content-code">
<pre class="highlight highlight-curl prettyprint">curl --location --request GET 'https://partner.api.bri.co.id/sandbox/v2/inquiry/888801000003301' \
-- master table
create table transactions (
id serial primary key,
code varchar(60) not null unique,
date integer not null,
value decimal(15,2) default 0,
remarks text
);
-- details table without generated column
@hidayat365
hidayat365 / generated_column.sql
Last active November 3, 2021 02:21
Generated Column Example
-- master table
create table transactions (
id serial primary key,
code varchar(60) not null unique,
date integer not null,
value decimal(15,2) default 0,
remarks text
);
-- details table without generated column
@hidayat365
hidayat365 / db_size.sql
Last active July 31, 2019 11:24
MySQL Database and Table Size Query
SELECT table_schema "DB Name",
Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size (MB)"
FROM information_schema.tables
GROUP BY table_schema;
SELECT table_name
, round(((table_rows) / 1024 / 1024), 2) as "Row Count (mil)"
, round(((data_length) / 1024 / 1024), 2) as "Data Size (MB)"
, round(((index_length) / 1024 / 1024), 2) as "Index Size (MB)"
, round(((data_length + index_length) / 1024 / 1024), 2) as "Table Size (MB)"
@hidayat365
hidayat365 / fk-basic.sql
Last active June 23, 2019 03:57
Dasar penggunaan Foreign Key (FK) di database relasional (RDBMS)
Nurs-MacBook-Pro:~ nurhidayat$ /Applications/XAMPP/bin/mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 307
Server version: 10.1.38-MariaDB Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
@hidayat365
hidayat365 / validate_pairs.php
Last active January 29, 2019 04:18
Tantangan PHP Group: Validasi Input Array Mencari data Pairs
<?php
function my_var_dump($prefix, $data) {
echo $prefix . ": ";
array_walk($data, function($val,$key) {
echo json_encode($val) . ' ';
});
echo "\n";
}
function validate_pairs($data, $sum) {
-- students table
create table murid (
id int auto_increment primary key,
nisn varchar(20) not null,
nama varchar(100) not null
);
-- kesalahan table
create table kesalahan (
id int auto_increment primary key,
@hidayat365
hidayat365 / grouping.sql
Created August 31, 2017 06:29
Grouping by transactions using custom group
-- ---------------------------------------
-- Generate Data
-- ---------------------------------------
CREATE table trans_history AS
SELECT 'TRANS-A' AS transactions, '2017-08-30 08:00:00' AS history UNION ALL
SELECT 'TRANS-A' AS transactions, '2017-08-30 08:10:00' AS history UNION ALL
SELECT 'TRANS-A' AS transactions, '2017-08-30 08:20:00' AS history UNION ALL
SELECT 'TRANS-A' AS transactions, '2017-08-30 08:30:00' AS history UNION ALL
SELECT 'TRANS-A' AS transactions, '2017-08-30 08:40:00' AS history UNION ALL
SELECT 'TRANS-A' AS transactions, '2017-08-30 08:50:00' AS history UNION ALL
@hidayat365
hidayat365 / sqlserver-tuning.sql
Last active February 3, 2021 12:06
Queries for SQL Server Performance Tuning
DBCC FREEPROCCACHE;
-- -----------------------
-- Find Long Running Query
-- Execute the query inside target database
-- -----------------------
SELECT st.text
, qp.query_plan
, qs.*
FROM (