Dasar query basis data dengan SQLite

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.
Dasar-dasar SQL soesanto.
MYSQL.
Database Create-Retrieve-Update-Delete (CRUD)
Database Android Dwi Muktianto
DDL & Aturan Referential
PEMROGRAMAN BASIS DATA
SQL: Queries II, Constraints & Triggers (Chap. 5 – Ramakrishnan)
SISTEM BASISDATA Lasmedi Afuan, ST.,M.Cs. SQL (S RUCTURE Q UERY L ANGUAGE ) Query/SQL : Bahasa standar yang digunakan untuk mengakses basisdata. Standar.
Manajemen Basis Data menggunakan SQL Server
Basis Data Bab 3 Structured Query Language (SQL).
PHP - MySQL.
CHANGE DATA CAPTURE.
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.
Pemrograman Web/MI/D3 sks
TRIGGER.
1 Bab 3 Structured Query Language (SQL) Basis Data
Microsoft SQL Server DDL dan DML dasar
Perancangan Database Pertemuan 07 s.d 08
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.
Data Types Data Definition Language Referential Constraint SQL Query
SQL (Structure Query Language)
BAHASA QUERY TERAPAN OLEH : HARSITI, ST.
METHOD, ARRAY DAN STRING
MANAJEMEN BASIS DATA Pertemuan 8 SUBQUERY.
Binary Search Tree. Sebuah node di Binary Search Tree memiliki path yang unik dari root menurut aturan ordering – Sebuah Node, mempunyai subtree kiri.
Cursor MI2163 Dasar Pemrograman Basis Data. Introduction Cursor merupakan suatu variabel yang digunakan untuk menampung hasil query yang terdiri atas.
Modul SBD-2 …….. SQL Server
Mengekspor, Menyalin, dan Mengimpor Data
Pertemuan after UTS Structure Query Language (SQL)
FUNGSI-FUNGSI AKSES MySql
SQL.
Bahasa query terpan.
Konsep Teknologi Informasi B
SQL (Structure Query Language)
Data Manipulation Languange (DML) Perintah INSERT dan DELETE
Konsep Teknologi Informasi B
Praktikum Berkas dan Basis Data
SQL OVERVIEW.
Sistem Manajemen Basis Data
Created By Amir Ali,S.Kom.,M.Kom
Structured Query Language (SQL)
As’ad Djamalilleil Database As’ad Djamalilleil
Pengelolaan Database Lanjutan 2
Structured Query Language
Pemrograman Web/MI/D3 sks
EXERCISE DML Part I Buatlah sebuah tabel baru nama = Dosen
PEMROGAMAN MOBILE ANDROID DATABASE : SQLiTE
Pemrograman mobile DATABASE ANDROID.
Android database sqlite
Basis Data Bab 3 Structured Query Language (SQL).
KULIAH “PRAKTIKUM BASIS DATA“ TEKNIK INFORMATIKA UNIVERSITAS MERCU BUANA Oleh : AFIYATI S.KOM, MT.
Pemrograman Web/MI/D3 sks
Referensi Bahasa MySQL
Pemrograman Web/MI/D3 sks
Membuat Query ACCESS Query adalah fasilitas untuk mengakses data dengan cara  yang memungkin bagi kita untuk menampilkan data-data dari database dalam.
Praktikum Sistem Basis Data - 2
Praktikum 2 - Sistem Basis Data 1
Pemrograman Web/MI/D3 sks
 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.
If you are an user, then you know how spam affects your account. In this article, we tell you how you can control spam’s in your ZOHO.
How do I Add or Remove a delegate to my Gmail account? Google launched delegation service 9 years ago for Gmail that allows you to give permission to access.
DATABASE.
Transcript presentasi:

Dasar query basis data dengan SQLite

Pokok Bahasan Basis Data Mobile dengan SQLite Membuat Basis Data Mobile Menginput data pada SQLite Membaca data Mengubah dan Menghapus data Menampilkan query dan hasil query basis data ke dalam log.

Membuat Basis Data C:\sqlite>sqlite3.exe mobile.db SQLite version 3.8.4.3 2014-04-03 16:53:12 Enter ".help" for usage hints. sqlite> .databases seq name file --- --------------- ---------------------- 0 main C:\sqlite\mobile.db

Contoh Struktur Tabel

Membuat Tabel create table contacts( id integer primary key autoincrement not null, name text, phone_number text ); Menampilkan list table dalam database sqlite> .tables Menampilkan skema table contacts sqlite> .schema contacts

Input Data SQLite sqlite> insert into contacts (name, phone_number) values (‘tester','0856414412xx'); values (‘Bejo Selamet','0856414413xx'); Note Kolom id tidak diisi, karena kolom otomatis melakukan autoincrement id

Menampilkan Isi Data sqlite> .header on sqlite> .mode column sqlite> select * from contacts; id name phone_number ---------- -------------- ------------ 1 Tester 0856414412xx 2 Bejo Selamet 0856414413xx Note : Kolom id terisi secara otomatis terurut

Mengubah Data Mengubah phone_number pada data yang memiliki id=2 sqlite> update contacts set phone_number='08564123456x' where id='2'; sqlite> .header on sqlite> .mode column sqlite> select * from contacts; id name phone_number ---------- -------------- ------------ 1 Tester 0856414412xx 2 Bejo Selamet 08564123456x

Menghapus Data Menghapus data yang memiliki id=2 sqlite> delete from contacts where id='2'; sqlite> .header on sqlite> .mode column sqlite> select * from contacts; id name phone_number --------- -------------- ------------ 1 Tester 0856414412xx

public long insert (String table, String nullColumnHack, ContentValues values) Convenience method for inserting a row into the database. Table the table to insert the row into NullColumnHack optional; may be null. SQL doesn't allow inserting a completely empty row without naming at least one column name. If your provided values is empty, no column names are known and an empty row can't be inserted. If not set to null, the nullColumnHack parameter provides the name of nullable column name to explicitly insert a NULL into in the case where your values is empty. values this map contains the initial column values for the row. The keys should be the column names and the values the column values Returns the row ID of the newly inserted row, or -1 if an error occurred

public void put (String key, byte[] value) Adds a value to the set. Parameters key the name of the value to put value the data for the value to put

public int update (String table, ContentValues values, String whereClause, String[] whereArgs) Convenience method for updating rows in the database. Table the table to update in Values a map from column names to new column values. null is a valid value that will be translated to NULL. whereClause the optional WHERE clause to apply when updating. Passing null will update all rows. whereArgs You may include ?s in the where clause, which will be replaced by the values from whereArgs. The values will be bound as Strings. Returns the number of rows affected

public int delete (String table, String whereClause, String[] whereArgs) Convenience method for deleting rows in the database. Table the table to delete from WhereClause the optional WHERE clause to apply when deleting. Passing null will delete all rows. WhereArgs You may include ?s in the where clause, which will be replaced by the values from whereArgs. The values will be bound as Strings. Returns the number of rows affected if a whereClause is passed in, 0 otherwise. To remove all rows and get a count pass "1" as the whereClause.

Menulis Log Log berguna ketika kita akan menginisialisasi ,melihat kinerja code kita dsb, di jme/j2me  kita dapat menggunakansystem.out.println untuk menampilkan log ke standart output di android kita  dapat menggunakan Log.d(“tag/judul”,”isi log anda”); jangan lupa import kebutuhan fungsi import android.util.Log; untuk tipe – tipe log Log.v(); // Verbose Log.d(); // Debug Log.i(); // Info Log.w(); // Warning Log.e(); // Error

Code Untuk Mampilkan Log // Reading all contacts Log.d("Reading: ", "Reading all contacts.."); List<Contact> contacts = db.getAllContacts(); for (Contact cn : contacts) { String log = "Id: "+cn.getID()+" ,Name: " + cn.getName() + " ,Phone: " + cn.getPhoneNumber(); // Writing Contacts to log Log.d("Name: ", log); }

Android Log Cat Report I am writing output to Log report. You can see your log report by going to  Windows ⇒ Show View ⇒ Other.. ⇒ Android ⇒ Log Cat.

SQLite Output Log

Sumber https://www.sqlite.org/cli.html http://www.androidhive.info/2011/11/android-sqlite-database- tutorial/ http://www.tutorialspoint.com/sqlite