MySQL Learning Path (ii) MySQL basic operation

Source: Internet
Author: User

Enter the database

  Use library name;

CREATE TABLE structure

Syntax: CREATE table library name. Table Name (

Field name data type constraint,

Field name data type constraint

Create Table text . T_user (    int),    varchar(ten

View all Tables

Show tables;

View field properties in a table

Desc from T_user;

Renaming table names

Table  to My_user;

Delete Table structure

Drop table My_user;

Delete a field from a table

Alter Table drop t_name;

Add Field

syntax; ALTER TABLE name add "column" Field name data type "First" after field name;

First, after is placed after a field, the default is the last;

Alter Table Add int After T_name; Alter Table Add int First;

Modify Field Properties

Syntax: ALTER TABLE name modify field Name property;

Alter Table varchar (ten);

Rename table field name

Syntax: ALTER TABLE name change old field name new field Name property;

Alter Table varchar (ten);

Delete a table

Syntax: drop table name;

Add data

Insert  into Values ("1", "Zhang San", "n"); Insert  into Values (2, "history"); -- The second method is recommended

Querying data

SELECT */field from table name where [condition];

Select *  from where id=2;

Update data

  Update table name Set field = value where condition;

Update set t_name=where id=2;

Delete data

  Delete from table name where condition;

Delete  from where id=2;

Modifying the proofing set for a database

Alter Table = Utf8_bin; Alter Table = utf8_general_ci;

MySQL Learning Path (ii) MySQL basic operation

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.