Articles by "Database"

Showing posts with label Database. Show all posts

The CREATE TABLE statement is used to create a table in a database.

Syntax :
            CREATE TABLE table_name
            (
              column_name1 data_type,
              column_name2 data_type,
              column_name3 data_type,
             ....
            )

Ex :
            CREATE TABLE Student
            (
              IdStudent int,
              FirstName char (50),
              LastName char (50),
              Addreas varchar (200)
             )




TAG: SQL statement, database, table, student

The CREATE INDEX statement is used to create indexes in tables.

Indexes allow the database application to find data fast; without reading the whole table.

SQL CREATE INDEX Syntax
Syntax :
            CREATE INDEX index_name  ON table_name (column_name)
Ex :
            CREATE INDEX IdStudent ON Student (LastName)


SQL CREATE UNIQUE INDEX Syntax
Syntax :
            CREATE UNIQUE INDEX index_name ON table_name (column_name)
Ex :
            CREATE INDEX IdStudent ON Student (LastName, FirstName)




TAG: SQL statement, database, table, student

To connect to the server, you will usually need to provide a MySQL user name when you invoke mysql and, most likely, a password. If the server runs on a machine other than the one where you log in, you will also need to specify a host name. Contact your administrator to find out what connection parameters you should use to connect (that is, what host, user name, and password to use). Once you know the proper parameters, you should be able to connect like this:


shell> mysql -h host -u user -p
Enter password: ********

host and user represent the host name where your MySQL server is running and the user name of your MySQL account. Substitute appropriate values for your setup. The ******** represents your password; enter it when mysql displays the Enter password: prompt.

If that works, you should see some introductory information followed by a mysql> prompt:

shell> mysql -h host -u user -p
Enter password: ********

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 25338 to server version: 5.0.89-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

The mysql> prompt tells you that mysql is ready for you to enter commands.

If you are logging in on the same machine that MySQL is running on, you can omit the host, and simply use the following:

shell> mysql -u user -p

If, when you attempt to log in, you get an error message such as ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2), it means that the MySQL server daemon (Unix) or service (Windows) is not running. Consult the administrator or see the section of Chapter 2, Installing and Upgrading MySQL that is appropriate to your operating system.

For help with other problems often encountered when trying to log in, see Section B.5.2, “Common Errors When Using MySQL Programs”.

Some MySQL installations allow users to connect as the anonymous (unnamed) user to the server running on the local host. If this is the case on your machine, you should be able to connect to that server by invoking mysql without any options:

shell> mysql

After you have connected successfully, you can disconnect any time by typing QUIT (or \q) at the mysql> prompt:

mysql> QUIT
Bye

On Unix, you can also disconnect by pressing Control-D.

Most examples in the following sections assume that you are connected to the server. They indicate this by the mysql> prompt.


Source : http://dev.mysql.com

* Essentially three books in one, provides thorough introductions to the PHP language, MySQL database, and shows you how these two technologies can be effectively integrated to build powerful websites.
* Provides over 500 code examples, including real-world tasks such as providing an auto-login feature, sending HTML-formatted email, testing password guessability, and uploading files via a Web interface.
* Updated for MySQL 5, includes new chapters introducing triggers, stored procedures, and views.

Interested in becoming a master of the PHP language and MySQL database but don't know where to begin? This bestselling book ranks among the most thorough and practical guides in print, covering all of the key concepts and features, and showing you how to effectively integrate PHP and MySQL to build powerful websites.

The book begins with a vast overview of PHP's capabilities, starting with a survey of the installation and configuration process on both the Windows and Linux platforms. Next, several chapters are devoted to basic PHP concepts, including variables, datatypes, arrays, functions, string manipulation, and processing user input. Other key PHP topics are also covered, including PEAR, session handling, LDAP integration, the Smarty templating engine, Web services, and PDO.

Next up is a presentation of MySQL's key features. You're first guided through MySQL's installation and configuration process, and are presented with an introduction to its storage engines, datatypes, administration utilities, security features, and data import/export facilities. New MySQL 5-specific chapters have been added in this edition, covering triggers, stored procedures, and views. Along the way, you'll gain insight into PHP's assortment of MySQL functions (using both the mysql and mysqli extensions), and learn how to create and execute queries, perform searches, and carry out key database tasks from within your Web application.
What You Will Learn from This Book

  • Install and configure Apache, PHP and MySQL on both Windows and Linux
  • Accept and process information submitted via HTML forms
  • Authenticate users and track user preferences and data using PHP's session-handling capabilities
  • Process Web-based file uploads using the HTTP_Upload PEAR package
  • Create your own RSS aggregator using Magpie, and process XML files in amazingly efficient fashion using SimpleXML
  • Use both command-line and graphical MySQL clients to effectively manage your data
  • Secure the MySQL server, creating roles and restricting access even at very granular levels
  • Effectively integrate PHP and MySQL to create dynamic, data-driven web applications

Who This Book Is For

This book is for the budding web developer searching for a powerful and low-cost solution to building flexible, scalable websites.

Read More : Beginning PHP and MySQL: From Novice to Professional, Third Edition

Pembahsan kali ini tentang dasar-dasar MySQL, buat yang sudah mahir share ilmunya disini donk. Perintah apa aja yang terdapat dalam MySQL ??

Perintah dalam MySQL ada 2 macam :
  1. Perintah untuk lingkungan MySQL itu sendiri
  2. Perintah untuk mengelola database

Perintah dalam lingkungan MySQL
Kalian dapat menggunakan perintah \h atau help, perintah ini untuk menampilkan daftar perintah yang dapat digunakan dalam lingkungan MySQL. Menggunkan perintah ada 2 cara yaitu \ diikuti dengan satu huruf atau dengan menuliskan secara lengkap perintahnya help . Di bawah ini daftar perintah yang digunakan dalam lingkungan MySQL serta kegunaannya

help (\h) : Menampilkan daftar perintah di lingkungan MySQL
? (\?) : Sinonim dari help
clear (\c) : Perintah menghapus
Connect (\r) : Menghubungkan kembali kepada database MySQL, dapat disertai dengan option db dan host
edit (\e) : Melakukan pengeditan perintah-perintah SQL yang ada di dalam buffer, dengan menggunakan editor teks default dari sistem Unix *)
exit (\q) : Keluar dari MySQL
go (\g) : Mengirimkan perintah kepada MySQL
ego(\G) : Mengirimkan perintah kepada MySQL, menampilkan hasiknya secara vertikal
print (\p) : Mencetak perintah saat ini
quit (\q) : Keluar dari MySQL
rehast (\#) : Membangun kembali hash
status (\s) : menampilkan status server MySQL
use (\u) : Membuat/mengganti koneksi kepada database
source (\.) : Mengeksekusi perintah SQL dari dalam file **)
tee (\t) : Mengarahkan keluaran untuk disimpan ke dalam file, selalu menambahkan hasil kepada file output **)
notee (\T) : Mencegah output supaya tidak ditulis ke dalam file **)

*) menunjukkan bahwa perintah ini hanya tersedia di lingkungan MySQL dengan sistem operasi *nik (Linux)
**) Perintah ini hanya ada pada MySQL di lingkungan Windows

MySQL dalam Windows mempunyai perintah tambahan notee, source dan tee, sedangkan dalam Linux tidak mempunyainya tetapi mempunyai perintah tambahan edit.

Perintah untuk mengelola Database

Pengelolaan database dapat dilakukan dengan menggunakan perintah-perintah SQL (Structured Query Language), bahasa yang khusus digunakan untuk melakukan akses database relasional.

Perintah SQL, dikelompokkan menjadi :

  • DDL (Data Definition Language)
  • DML (Data Manipulation Language)
  • DCL (Data Control Language)

DDL merupakan perintah yang digunakan untuk membuat dan mendefinisikan database dan stuktur datanya.

DML merupakan perintah yang digunakan untuk melakukan pengelolaan data yang ada dalam database.

DCL merupakan perintah untuk melakukan pendifinisian pemakai yang boleh mengakses database dan apa saja privilegenya.

Wah dah banyak nih tulisannya, mungkin itu yang bisa saya sampaikan, dan semoga pembahasan tersebut bermanfaat bagi pembacanya,, amin...

Buat kalian yang ingin belajar tentang database dengan menggunakan open source terutama MySQL simak deh penjelasan berikut :

MYSQL merupakan software siatem manajemen database (Database Manajemen System - DBMS) yang sangat populer di kalangan pemrograman web, terutama di lingkungan Linux dengan menggunakan script PHP dan Perl. Software database ini kini telah tersedia juga pada platform sistem operasi Windows (98/ME ataupun NT/2000/XP).

MySQL kini dikenal sebagai software manajemen open source, sebelumnya merupakan software shareware. Shareware adalah suatu software yang dapat didistribusikan secara bebas untuk keperluan penggunaan secara pribadi, tetapi jika digunakan secara komersial maka pemakai harus membayar lisensi dari pembuatnya, sedangkan open source menjadikan software dapat didistribusikan secara bebas dapat dipergunakan untuk keperluan pribadi ataupun komersial, lebih dari setengah juta server yang memasangnya termasuk didalamnya yahoo!, MP3.com, Motorola, Nasa, Silicon Graphics, HP, Xerox, Cisco, dan Texas Instruments.

Penghargaan terhadap MySQL

MyQL mendapatkan pengharagaan sebagai database terbaik untuk server Linux versi Linux Magazine tahun 2002 dan 2001, dan sebagai database favorite pada tahun 2000
Mungkin ini bisa menambah wawasan kalian dan pembahasan selanjutnya tentang dasar-dasar MySQL....

Untuk perancangan database kalian harus mengetahui lebih detail tentang spesifikasi tipe data yang tersedia dalam MySQL, sehingga pada saat perancangan dapat dengan tepat memilih tipe data berkaitan dengan optimasi penggunaan space di dalam storage komputer.

Tipe data secara umum dapat dikelompokkan menjadi data,

1. Nilai Numerik : semua data yang berupa bilangan (angka) yang dapat dimanipulasikan dengan menggunakan operasi matematika.

Nilai Numerik dibedakan ada dua :

1. Integer : tidak memiliki pecahan
2. Float : memiliki angka pecahan

Tipe Data Numerik :

TINYINT : Nilai integer yang sangat kecil
SMALLINT : Nilai integer yang kecil
MEDIUMINT : Integer dengan nilai medium
INT : Integer dengan nilai standar
BIGINT : Integer dengan nilai besar
FLOAT : Bilangan desimal dengan single-precission
DOUBLE : Bilangan desimal dengan double-precission
DECIMAL : Bilangan float (desimal) yang dinyatakan sebagai string
Spesifikasi tipe data numerik
TINYINT : Signed : -128 s/d 127, Unsigned : 0 s/d 255, Byte = 1
SMALLINT : Signed : -32768 s/d 32767, Unsigned : 0 s/d 255, Byte = 2
MEDIUMINT : Signed : -8388608 s/d 8388607, Unsigned : 0 s/d 16777215, Byte = 3
INT : Signed : -2147483648 s/d 2147483647, Unsigned : 0 s/d 4294967295, Byte = 4
BIGINT : Signed : -9223372036854775808 s/d 9223372036854775807, Unsigned : 0 s/d 18446744073709551615, Byte = 8
FLOAT : Minimum : +- 1.175494351e-38, Maksimum : +- 3.402823466e+38, Byte : 4
DOUBLE : Minimum : +- 2.2205738585072014e-308, Maksimum : +- 1.7976931348623457e+308, Byte : 8
DECIMAL (M,D) : tergantung pada nilai M dan D, Byte : M+2


Keterangan :

Signed : data yang disimpan dalam suatu kolom bisa – s/d +
Unsigned : Digunakan agar data yang dimasukkan bukan data negatif, (>=0).

Untuk pembahasan “Nilai String” dan “Nilai tanggal dan jam” akan saya bahas lain waktu, so tungguin aja selanjutnya....
Bersambung....

Author Name

Contact Form

Name

Email *

Message *

Powered by Blogger.