Last active
February 8, 2021 11:51
-
-
Save krisnachy/4c3558585400819d0e1aaac02ab717ce to your computer and use it in GitHub Desktop.
Hasil PostTest Database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--membuat database | |
CREATE DATABASE tugas; | |
--mengganti nama database | |
ALTER DATABASE tugas RENAME TO tugasbaru; | |
--membuat tabel | |
CREATE TABLE books ( | |
id INTEGER PRIMARY KEY, | |
isbn INTEGER, | |
judul VARCHAR(100) NOT NULL, | |
sinopsis TEXT NOT NULL, | |
penulis VARCHAR(100) NOT NULL, | |
genre VARCHAR(25)); | |
--menambah tabel baru | |
ALTER TABLE books ADD COLUMN harga INTEGER; | |
--menghapus tabel | |
DROP TABEL books; | |
--menambahkan data tabel | |
INSERT INTO books ( | |
id, isbn, judul, sinopsis, penulis, genre, harga | |
) VALUES (1, 123456, 'latihan', 'Mencoba database', 'krisna', 'horor', 20000); | |
--menambahkan data lain | |
INSERT INTO books (2, 12534, 'dua', 'testing', 'lain', 'fiksi', 30000); | |
INSERT INTO books (3, 1876234, 'tiga', 'testing3', 'krisna', 'thriller', 30000); | |
INSERT INTO books (4, 12368, 'empat', 'testing4', 'cahya', 'lainnya', 30000); | |
INSERT INTO books (5, 14539948, 'lima', 'testing5', 'lain', 'fiksi', 30000); | |
--mengecek data | |
SELECT * FROM books; | |
-- menampilkan data secara spesifik | |
SELECT judul, penulis, genre, harga FROM books WHERE genre = 'fiksi'; | |
--memperbarui data | |
UPDATE books SET genre = "fiksi"; | |
--menghapus data | |
DELETE FROM books WHERE books.penulis = "krisna"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment