Tuesday, January 24, 2023

Array Pada PostfreSQL

 



1. Buat Table

CREATE TABLE person_details (  
    id serial PRIMARY KEY,  
    person_name VARCHAR (200) ,  
    mobile_numbers TEXT []  
);

2. Insert 

2.1. Single Record

INSERT INTO person_details (person_name, mobile_number)  
VALUES('Maria Smith',ARRAY [ '(444)-333-1234','(555)-333-5432' ]);

2.2. Multi Record 

INSERT INTO person_details (person_name, mobile_number)  
VALUES('Mike Taylor','{"(444)-333-1234"}'),  
('Emma Garcia','{"(568)-333-5678"}'),  
('David Smith','{"(444)-333-7658","(308)-589-23458"}'); 


3. Select 

3.1. SELECT person_name, mobile_number  FROM person_details;  

3.2. SELECT person_name, mobile_number[1]  FROM person_details; 

3.3. SELECT person_name  FROM person_details  WHERE mobile_number[2]='(308)-589-23458'; 

3.4. Arrays data type : SELECT person_name,  unnest(mobile_number) FROM person_details;  

3.5. Search  : SELECT person_name, mobile_number  FROM person_details  
WHERE '(555)-333-5432' = ANY (mobile_number); 


4. Update

4.1. UPDATE person_details  SET mobile_number [2] = '(308)-859-54378'  WHERE ID = 4;  

4.2. UPDATE person_details  SET mobile_number = '{"(308)-859-54378"}'  WHERE ID = 4;  


Memunculkan Simbol & Emoji Pada OS Mac

  Memunculkan Simbol & Emoji  1. Buka aplikasi Pages / Notes pada Macbook. 2. Klik pada Menubar Edit --> Pilih Emoji and Symbols a...