0% found this document useful (0 votes)
12 views1 page

Query Postgresql

The document contains a series of SQL commands for user and table management in a database. It includes creating, altering, granting, and revoking user privileges, as well as modifying a table structure and performing various data manipulation operations. Additionally, it features commands for querying and managing database connections.

Uploaded by

arzydewanto
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

Query Postgresql

The document contains a series of SQL commands for user and table management in a database. It includes creating, altering, granting, and revoking user privileges, as well as modifying a table structure and performing various data manipulation operations. Additionally, it features commands for querying and managing database connections.

Uploaded by

arzydewanto
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

CREATE USER aras_user WITH PASSWORD ‘123admin’


2. DROP USER aras_user
3. ALTER USER aras_user WITH PASSWORD ‘123user’
4. ALTER USER aras_user WITH SUPERUSER
5. ALTER USER aras_user WITH NOSUPERUSER
6. GRANT SELECT ON TABLE nama_tabel TO nama_user;
7. GRANT ALL ON TABLE nama_tabel TO nama_user;
8. GRANT ALL ON ALL TABLES IN SCHEMA public TO nama_user;
9. GRANT ALL PRIVILEGES ON DATABASE mydb TO aras_user
10. REVOKE SELECT ON TABLE nama_tabel FROM nama_user;
11. REVOKE ALL ON TABLE nama_tabel FROM nama_user;
12. REVOKE ALL ON ALL TABLES IN SCHEMA public FROM nama_user;
13. REVOKE ALL PRIVILEGES ON DATABASE mydb FROM aras_user;
14. ALTER TABLE pegawai ADD COLUMN email VARCHAR(100);
15. ALTER TABLE pegawai DROP COLUMN email;
16. ALTER TABLE pegawai RENAME TO data_pegawai;
17. ALTER TABLE pegawai RENAME COLUMN nama_lama TO nama_baru;
18. ALTER TABLE pegawai ALTER COLUMN nama SET NOT NULL;
19. ALTER TABLE pegawai ALTER COLUMN umur SET DEFAULT 25;
20. ALTER TABLE pegawai ALTER COLUMN nama DROP NOT NULL;
21. ALTER TABLE pegawai ADD PRIMARY KEY (id);
22. INSERT INTO pegawai (nama, email, umur) VALUES ('Budi', 'budi@[Link]', 25),
('Citra', 'citra@[Link]', 28);
23. SELECT * FROM pegawai;
24. SELECT nama, email FROM pegawai;
25. SELECT * FROM pegawai WHERE umur > 27;
26. SELECT * FROM pegawai ORDER BY umur DESC;
27. UPDATE pegawai SET umur = 35, nama = 'Andi Update' WHERE id = 1;
28. DELETE FROM pegawai WHERE id = 1;
29. DELETE FROM pegawai;
30. TRUNCATE TABLE pegawai;
31. UPDATE presensi SET keterangan = 'Hadir' FROM pegawai WHERE presensi.pegawai_id
= [Link] AND [Link] = 'Andi';
32. \l
33. \list
34. \q
35. \dt

You might also like