PRAKTIKUM 3 PEMROGRAMAN BASIS DATA. Menghapus baris  Deleting rows- DELETE FROM Use the DELELE FROM command to delete row(s) from a table, with the following.

Slides:



Advertisements
Presentasi serupa
Basis Data 2.
Advertisements

SQL – DML.
MATA KULIAH : “LOGIKA DAN ALGORITMA”
Pertemuan 2 : Dasar-dasar SQL SBD C – Senin, Frank & Rudy
SISTEM BASIS DATA INTRO-5. •Setelah mengikuti perkuliahan ini diharapkan mahasiswa dapat mengerti : 1.Aplikasi perintah SQL ke MySql Server 2.Mengerti.
Database MySQL.
PERINTAH SQL.
Dasar-dasar SQL soesanto.
MYSQL.
Database Create-Retrieve-Update-Delete (CRUD)
DDL & Aturan Referential
Pelatihan SisFo Kampus
CHANGE DATA CAPTURE.
Internet Programming MySQL
Pemrogramn Berorientasi Obyek MySQL
DDL & Aturan Referential
Pemrograman Visual II Database Management System (DBMS) Oleh: Erna Sri Hartatik, S.Kom
SQL 2. Database TRANSACTION Tabel yang terlibat : Customer berisi data pelanggan (nama, alamat, dll) OderInfo berisi info pemesanan oleh pelanggan (tgl.
Praktek Pemograman Client-Server
Pemrograman Web/MI/D3 sks
TRIGGER.
Microsoft SQL Server DDL dan DML dasar
Perancangan Database Pertemuan 07 s.d 08
Data Definition Language dan Data Manipulation Language
Antonius Wahyu Sudrajat, S. Kom., M.T.I. Perintah SQL: Data Definition.
Data Types Data Definition Language Referential Constraint SQL Query
Koneksi PHP ke Database MySQL
Mengelola Security Database
TRIGGER.
Antonius Wahyu Sudrajat, S. Kom., M.T.I. Perintah SQL: Data Definition.
Dasar query basis data dengan SQLite
Pengenalan Database MySQL
Data Definition Language (DDL)
Mengekspor, Menyalin, dan Mengimpor Data
SQL (Structure Query Language)
PEMASARAN BERBASIS WEB
FUNGSI-FUNGSI AKSES MySql
Connect to the Server - Putty
Operasi Relasional Basis Data
Konsep Teknologi Informasi B
SQL (Structure Query Language)
View dan Trigger Materi 5
PDM.
Manajemen Basis Data menggunakan SQL Server
Connect to the Server - Putty
PEMASARAN BERBASIS WEB
DESAIN BASIS DATA-Bagian 3
TRIGGER.
SQL OVERVIEW.
Structured Query Language (SQL)
Data Definition Language (DDL)
Pengembangan Web Ramos Somya, S.Kom., M.Cs.
Structured Query Language
Pemrograman Web/MI/D3 sks
Biodata…… Nama : Muhammad Yunus Alamat : Getap Asal : Sakra Lotim
EXERCISE DML Part I Buatlah sebuah tabel baru nama = Dosen
Pemrograman Berorientasi Platform (IN315B) Ramos Somya, S.Kom., M.Cs.
Pengenalan mySQL database
CREATE, MODIFY, & DELETE TABLE
Pemrograman Web/MI/D3 sks
Referensi Bahasa MySQL
Pemrograman Web/MI/D3 sks
Praktikum Sistem Basis Data - 2
Praktikum 2 - Sistem Basis Data 1
Pemrograman Web/MI/D3 sks
MEMBANGUN DATABASE DENGAN MySQL
 Zoho Mail offers easy options to migrate data from G Suite or Gmail accounts. All s, contacts, and calendar or other important data can be imported.
Pengantar Teknologi SIM 2 (pertemuan 7)
Draw a picture that shows where the knife, fork, spoon, and napkin are placed in a table setting.
Transcript presentasi:

PRAKTIKUM 3 PEMROGRAMAN BASIS DATA

Menghapus baris  Deleting rows- DELETE FROM Use the DELELE FROM command to delete row(s) from a table, with the following syntax: -- Delete all rows from the table. Use with extreme care! Records are NOT recoverable!!! DELETE FROM tableName -- Delete only row(s) that meets the criteria DELETE FROM tableName WHERE criteria

contoh  mysql> DELETE FROM products WHERE name LIKE 'Pencil%';  mysql> SELECT * FROM products;

 Beware that "DELETE FROM tableName" without a WHERE clause deletes ALL records from the table. Even with a WHERE clause, you might have deleted some records unintentionally. It is always advisable to issue a SELECT command with the same WHERE clause to check the result set before issuing the DELETE (and UPDATE).

Loading/exporting data from/to a text file  There are several ways to add data into the database: (a) manually issue the INSERT commands; (b) run the INSERT commands from a script; (c) load raw data from a file using LOAD DATA or via mysqlimport utility.

LOAD DATA LOCAL INFILE... INTO TABLE... Besides using INSERT commands to insert rows, you could keep your raw data in a text file, and load them into the table via the LOAD DATA command. For example, create the following text file called "produk_in.csv", where the values are separated by ','. The file extension of ".csv" stands for Comma-Separated Values text file. \N,PENC,Pensil 3B,500,3000 \N,PENC,Pensil 4B,300,3500 \N,PENC,Pensil 5B,800,3750 \N,PENC,Pensil 6B,400,4000

mysql> LOAD DATA LOCAL INFILE 'd:/produk_in.csv' INTO TABLE produk COLUMNS TERMINATED BY ',' LINES TERMINATED BY '\r\n';

Notes:  You need to provide the path (absolute or relative) and the filename. Use Unix-style forward-slash '/' as the directory separator, instead of Windows-style back-slash '\'.  The default line delimiter (or end-of-line) is '\n' (Unix-style). If the text file is prepared in Windows, you need to include LINES TERMINATED BY '\r\n'. For Mac, use LINES TERMINATED BY '\r'.  The default column delimiter is "tab" (in a so-called TSV file - Tab-Separated Values). If you use another delimiter, e.g. ',', include COLUMNS TERMINATED BY ','.  You must use \N (back-slash + uppercase 'N') for NULL.

Select …into outfile … Lihat hasil file yang dibuat pada d:/…

More than one tables

One to many relationship  Masing-masing produk memiliki satu suplier, dan setiap suplier menyuplai minimal nol atau lebih produk.  Buat tabel suplier dengan atribut id_supl(int), nama_supl (varchar(3)), dan telp (char(8)) Id_supl (int)Nama_supl(varchar)Phone (char(8)) 501Perusahaan ABC Perusahaan XYZ Perusahaan KLM

Tabel Id_produkKode_produkNama_produkJumlahHargaId_supl 1001PENPulpen merah PENPulpen Hitam PENPulpen biru PENCPensil 6B PENCPensil 5B PENCPensil 4B PENCPensil 3B

 Buat tabel suplier

 Masukkan data suplier

 Buat kolom id_suplier pada tabel produk

 Tambahkan id_suplier sebagai foreign key pada tabel produk

 Ganti id supl pada masing-masing produk

Select with Join  SELECT command can be used to query and join data from two related tables. For example, to list the product's name (in products table) and supplier's name (in suppliers table), we could join the two table via the two common supplierID columns

 Join via where clause (legacy and not recommended)

 Gunakan alias ‘AS’ untuk menampilkan nama kolom

Many to Many Setiap produk dapat disuplai oleh banyak suplier dan setiap suplier dapat menyuplai banyak produk. Buat sebuah tabel baru, sebagai tabel penghubung (junction/join tabel) yang diberi nama tabel suplier_produk.

Tabel suplier_produk Id_produk (foreign key)Id_supl (foreign key)

 Masukkan nilai untuk suplier_produk

 Hapus kolom id_supl pada tabel produk, karena ini hanya berlaku pada one to many relationship.  Sebelum menghapus kolom id_supl, kita hilangkan dulu foreign key yang ada pada column tersebut.  Karena key merupakan constraint yang diberikan oleh sistem, maka kita masuk ke sistem databasenya.

One to one relationship

Backup  The syntax for the mysqldump program is as follows: -- Dump selected databases with --databases option > mysqldump -u username -p --databases database1Name [database2Name...] > backupFile.sql -- Dump all databases in the server with --all-databases option, except mysql.user table (for security) > mysqldump -u root -p --all-databases --ignore-table=mysql.user > backupServer.sql -- Dump all the tables of a particular database > mysqldump -u username -p databaseName > backupFile.sql -- Dump selected tables of a particular database > mysqldump - u username -p databaseName table1Name [table2Name...] > backupFile.sql

Backup  Keluar dulu ke bin Lihat hasilny pada d:/projek