Querying Data
Querying Data
mysql>
->
->
->
Querying data with .sql scripts: Querying data dengan. Sql skrip:
Memasukkan data
April 14, 2009 Tinggalkan sebuah Komentar
Perintah dasar mysql pada perintah baris:
% mysql Mysql%
mysql> USE wbluhm ; mysql> USE wbluhm;
mysql> SELECT * FROM books; mysql> SELECT * FROM buku;
mysql> INSERT INTO books mysql> INSERT INTO buku
-> VALUES ("My Life", "Mickey Mouse", "Disney", -> NILAI ( "My
Life", "Mickey Mouse", "Disney",
->
"Biography", "What can I say?", 9.95); -> "Biografi",
"Apa yang bisa saya katakan?", 9,95);
mysql> SELECT * FROM books; mysql> SELECT * FROM buku;
mysql> DELETE FROM books WHERE title="My Life"; mysql> DELETE FROM buku
WHERE judul = "My Life";
mysql> SELECT * FROM books; mysql> SELECT * FROM buku;
mysql> exit; mysql> exit;
% %
Inserting data with .sql scripts: Memasukkan data dengan. Sql skrip:
SQL script example: populate_books.sql SQL script contoh:
populate_books.sql
Membuat Tabel
April 14, 2009 Tinggalkan sebuah Komentar
Perintah dasar mysql pada perintah baris:
% mysql Mysql%
mysql> SHOW DATABASES; mysql> SHOW database;
mysql> USE wbluhm ; mysql> USE wbluhm;
mysql> SHOW TABLES; mysql> SHOW TABEL;
mysql> CREATE TABLE dummy ( first_name CHAR(20) , last_name CHAR(20) );
mysql> CREATE TABLE dummy (FIRST_NAME CHAR (20), last_name CHAR (20));
Creating tables from .sql scripts Menciptakan dari meja. Sql skrip
SQL script example: create_books.sql SQL script contoh: create_books.sql
-- creates the table books in database wbluhm - Membuat tabel dalam
database buku wbluhm
CREATE TABLE books
( (
title
author
publisher
topic
comment
price
) )
% mysql wbluhm
For more examples, see some of the scripts from the samp_db database in Untuk lebih
contoh, lihat beberapa script dari samp_db dalam database
/users/science/wbluhm/mysql/create_*.sql / user / ilmu / wbluhm /
mysql / create_ *. sql
Complete table of all column types on mysql.com Lengkap tabel semua jenis kolom di
mysql.com
Ditulis dalam Uncategorized
Mengakses MySQL
April 14, 2009 Tinggalkan sebuah Komentar
Mengakses MySQL pada baris perintah
(The last three steps need to be performed only once.) (Tiga langkah terakhir yang perlu
dilakukan sekali saja.)
Type Tipe
% source .alias
% mysql -h multivac
Or Atau
log into multivac (used to be spirit ) login ke multivac (dahulu roh)
ssh multivac
The database that you can use is the same one as your username, plus samp_db (currently,
more may be granted later). Database yang dapat Anda gunakan adalah yang sama sebagai
salah satu nama pengguna, plus samp_db (saat ini, lebih mungkin diberikan kemudian).
You may create tables, drop tables, etc. inside your own database. Anda dapat membuat tabel,
drop tabel, dll di dalam database Anda sendiri. samp_db or others which you may browse
may not be deleted, or dropped. samp_db atau orang lain yang dapat mengakses tidak dapat
dihapus, atau menurun.
Accessing MySQL from any machine Mengakses MySQL dari mesin
Your_Shell% mysql -h multivac.sdsc.edu -u wbluhm --password="" wbluhm
Your_Shell% mysql-h multivac.sdsc.edu-u wbluhm - password = "" wbluhm
(This assumes that you have the client installed on your machine and the PATH set properly.)
(Hal ini menganggap bahwa Anda memiliki klien yang diinstal pada komputer Anda dan
PATH ditetapkan dengan benar.)
Executing MySQL scripts on the command line (outside of MySQL) Pelaksana MySQL
skrip pada baris perintah (di luar MySQL)
% mysql wbluhm
% mysql -t wbluhm
try { try (
Class.forName("org.gjt.mm.mysql.Driver").newInstance
Class.forName ( "org.gjt.mm.mysql.Driver"). NewInstance ();
} )
catch (Exception E) { catch (Exception e) (
System.err.println("Unableoad driver"); System.err.println
( "Tidak dapat memuat driver");
E.printStackTrace(); E.printStackTrace ();
} )
try { try (
Connection C = DriverManager.getConnection( Koneksi C =
DriverManager.getConnection (
"jdbc:mysql://multivac.sdsc.edu/ wbluhm "," wbluhm ","");
"JDBC: mysql: / / multivac.sdsc.edu / wbluhm", "wbluhm ","");
Statement Stmt = C.createStatement(); Pernyataan Stmt =
C.createStatement ();
ResultSet RS = Stmt.executeQuery ResultSet RS =
Stmt.executeQuery
("SELECT title, author, comment " + ( "SELECT judul, penulis,
komentar" +
" FROM books WHERE topic=\"Java\""); "FROM buku WHERE topik =
\" Jawa \ "");
while (RS.next()) { sementara (RS.next ()) (
System.out.print("\"" + RS.getString(1) + "\"");
System.out.print ( "\" "+ RS.getString (1) +" \ "");
System.out.print(" by " + RS.getString(2));
System.out.print ( "oleh" + RS.getString (2));
System.out.println(": " + RS.getString(3));
System.out.println ( ":" + RS.getString (3));
} )
C.close(); C.close ();
RS.close(); RS.close ();
Stmt.close(); Stmt.close ();
} )
catch (SQLException E) { catch (SQLException e) (
System.out.println("SQLException E.getMessage());
System.out.println ( "SQLException:" + E.getMessage ());
System.out.println("SQLState " + E.getSQLState());
System.out.println ( "SQLState:" + E.getSQLState ());
System.out.println("VendorError+ E.getErrorCode());
System.out.println ( "VendorError:" + E.getErrorCode ());
} )
} )
} )