Inserting rows · Memasukkan baris
Adding rows with INSERT
INSERT adds a new row to a table. List the columns, then a matching set of VALUES:
Text goes in single quotes; numbers do not. The values must line up with the columns, in the same order.
Menambahkan baris dengan INSERT
INSERT menambahkan baris baru ke dalam tabel. Cantumkan kolom-kolomnya, lalu sekumpulan VALUES yang sesuai:
INSERT INTO product (code, title, price, in_stock)
VALUES ('P04', 'Ruler', 1.20, 75);
Teks ditulis dalam tanda kutip tunggal; angka tidak. Nilai-nilai harus sejajar dengan kolom-kolomnya, dalam urutan yang sama.
Seeing the effect
INSERT changes the data but returns no rows itself, so Run just reports how many rows changed. To see the new row, run a SELECT afterwards.
The checker does this for you: it runs your INSERT, then reads the table back to confirm your row is there.
Melihat efeknya
INSERT mengubah data tetapi tidak mengembalikan baris sendiri, sehingga Run (Jalankan) hanya melaporkan berapa banyak baris yang berubah. Untuk melihat baris baru, jalankan SELECT setelahnya.
Pengecek melakukan hal ini untuk Anda: ia menjalankan INSERT Anda, lalu membaca tabel kembali untuk memastikan baris Anda ada di sana.
Common mistakes
- The values must line up with the columns in order and type.
- Quote text values with single quotes.
Kesalahan Umum
- Nilai-nilai harus sejajar dengan kolom-kolomnya secara berurutan dan bertipe.
- Kutip nilai teks dengan tanda kutip tunggal.
Add a new product to the product table: code 'P04', title 'Ruler', price 1.20, in_stock 75. · Tambahkan produk baru ke tabel product: kode 'P04', judul 'Ruler', harga 1.20, in_stock 75.
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.
Add a new customer to the customer table: id 5, name 'Eve', city 'York'. List the columns you are filling, then give the matching VALUES. · Tambahkan customer baru ke tabel customer: id 5, name 'Eve', city 'York'. Daftar kolom yang Anda isi, lalu berikan matching VALUES.
Click Run to see the output here. · Klik Jalankan untuk melihat output di sini.