Common MySQL Commands

Source: Internet
Author: User
Tags mysql commands

Example 1: Establishing a database named XHKDB
mysql> CREATE DATABASE xhkdb;

Example 2: Displaying a database

Command: Show databases (note: There is a last s)
mysql> show databases;

Example 3: Deleting a database

Example: Delete a database named Xhkdb
mysql> drop Database xhkdb;

Example 3: Working with databases

For example: If the XHKDB database exists, try to access it:
mysql> use XHKDB;
Screen tip: Database changed

--

Example 1: Creating a Table

For example, to create a table named MyClass,

whether to empty degree /tr>
field name numeric type data width if primary key automatically increases default
ID int 4 no primary key auto_increment  
name char no      
Sex int 4 no     0
Double the is      


Mysql> Create table MyClass (
> ID int (4) NOT NULL primary key auto_increment,
> Name char () NOT NULL,
> Sex int (4) NOT null default ' 0 ',
> Degree double (16,2));

Example 2: Deleting a table

Example: Deleting a table with a table named MyClass
mysql> drop table MyClass;

Example 3: Inserting data

mysql> INSERT INTO MyClass values (1, ' Tom ', 96.45), (2, ' Joan ', 82.99), (2, ' Wang ', 96.59);

Example 4: Updating data

Syntax: Update table name SET field = new value,... WHERE condition
mysql> Update MyClass set name= ' Mary ' where id=1;

Common MySQL Commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.