Perintah dasar mysql melalui cmd

Now I will continue the second part of the MySQL database tutorial. Which in the previous section I have written the basic structure of the MySQL database. All of this tutorial I will discuss with a simple so that you all can easily understand. If any of the writing or the lack of understanding of this tutorial, please give your comment.


BASIC SQL

    
* Create a new database.
    
* Create a new table.
          
o Type column
          
o Indexes and Keys
    
* Manipulation of data.
          
o inserting
          
o Retrieving
          
o Updateing
          
o Deleting
    
* Change the table.
1. Creating a New Database

    
* Display database

          
mysql> SHOW DATABASES;

    
* Create a database

          
mysql> CREATE DATABASE [Name databasemu];

    
* Using a database

          
mysql> USE [Name databasemu];

    
* Delete a database

          
mysql> DROP DATABASE [Name databasemu];
2. Creating a New Table

    
* Display table

          
mysql> SHOW TABLES FROM [Name databasemu];

    
* Create table

          
mysql> CREATE TABLE [Name tablemu] ([column name] [column type], [...]);

      
For example:

          
mysql> CREATE TABLE member (ID int (100), Name varchar (255));

    
* Displays column

          
mysql> SHOW COLUMNS FROM [Name tablemu];

    
* Removing table

          
mysql> DROP TABLE [Name tablemu];
Type column commonly used in MySQL:

    
* Type String
          
o char
          
o varchar
          
o text
          
blob o
    
* Type Numeric
          
o int
          
o tinyint
          
o int zerofill
          
o int not null
          
o float
          
o double
          
o decimal
Adds Indexing and Keys into the Table:

    
mysql> ALTER TABLE [Name tablemu] ADD INDEX ([column name to assign to index]);
For example:

    
mysql> ALTER TABLE member ADD INDEX (Name);

    
mysql> CREATE TABLE [Name tablemu] ([column name] [column type], [...], PRIMARY KEY ([name of the column that want to be given key]));
For example:

    
mysql> CREATE TABLE member (ID int (100), Name varchar (255), PRIMARY KEY (ID));
3. Data Manipulation

    
* Entering data

          
mysql> INSERT INTO [Names tablemu] ([column name]) VALUES ([Content / Value column]);

      
For example:

          
mysql> INSERT INTO member (ID, Name) VALUES (1, "Yustian");

    
* Update data

          
mysql> UPDATE [Name tablemu] SET [Name column] = [Fill / column value] WHERE [Condition of the desired data];

      
For example:

          
mysql> UPDATE members SET name = "Yustian" WHERE ID = 1;

    
* Deleting data

          
mysql> DELETE FROM [Name tablemu] WHERE [Condition of the desired data];

      
For example:

          
mysql> DELETE FROM WHERE ID = 1 member;
4. Changing Table

    
* Rename a table

          
mysql> ALTER TABLE [Name tablemu] RENAME [new name];

      
For example:

          
mysql> ALTER TABLE RENAME member of my members;

    
* Adding a column to the table

          
mysql> ALTER TABLE [Name tablemu] ADD [column name] [column type], [...];

      
For example:

          
mysql> ALTER TABLE member ADD Name char (100);

    
* Delete column

          
mysql> ALTER TABLE [Name tablemu] DROP [column name];

      
For example:

          
mysql> ALTER TABLE DROP member's name;

    
* Changing the name and type column

          
mysql> ALTER TABLE [Name tablemu] CHANGE [column name] [new column name] [column type], [...];

      
For example:

          
mysql> ALTER TABLE CHANGE member Username Name varchar (255);
Similarly, some of MySQL are still many more articles that will I write in this YusianBlog among operators in the MySQL, MySQL Query and many more. Hopefully it can all help you to learn MySQL with ease.

Share it to your friends..!

Share to Facebook Share this post on twitter Bookmark Delicious Digg This Stumbleupon Reddit Yahoo Bookmark Furl-Diigo Google Bookmark Technorati Newsvine Tips Triks Blogger, Tutorial SEO, Info

1 komentar:

  1. Erwinsyah said...:

    wah... sangat berguna.!! terimakasih informasinya.. update terus ya. salam sukses untukj blog kamu. thanks

Post a Comment

 
Ridho Technology © 2012 | Template by Ridho Technology