LAMP 3.3 MySQL Common operation-1

Source: Internet
Author: User

There is a graphical management of MySQL tool called phpMyAdmin, how to manage and operate MySQL under the command line.

First go to MySQL

Mysql-uroot-pwangshaojun

See which libraries are available

> show databases;

Switch to a library

> Use Discuz

See which library is currently in

Select Database ();

View the currently logged on user

Select User ();

View version

Select version ();

Switch to library Yes

> Use discuz;

View Table

> Show tables;

See what fields are in the table

Descdesc Pre_ucenter_vars;

View creation statements for a table

Show CREATE TABLE pre_ucenter_vars\g;

////////////////////////////////////////////////////////////////////////////////////////////////////////

Create library, library name: Wangshaojun

> CREATE Database Wangshaojun;

Switch to the Wanghsaojun library.

Use Wangshaojun;

Create a table

int (4char(+)) Engine=myisam DEFAULT CHARSET=GBK;

Create a table with the table name: TB1. There are two fields, one called ' ID ' format int length up to 4 bits one called ' name ' format is char maximum of 40. Specifies the engine. Character Set GBK.

Show all tables under the current library

> Show tables;

Analysis Table TB1

> desc tb1;

Inserting data into a table

> INSERT into TB1 values (1,'wangshaojun');

Id,name are 1 and Wangshaojun, respectively.

Select a bit

Select  from TB1;

Continue to add

> INSERT into TB1 values (2,'Denny');

You can also add a single character

> INSERT into TB1 (' id ') VALUES (2);
> INSERT into TB1 (' id ') VALUES (4);

You can also add the name

> INSERT into TB1 (' name ') VALUES ('+');

can also be specified in reverse order

> INSERT into TB1 (' name ', ' ID ') VALUES ('6');

Updating data in tables

set id=5where'in ';

Update the ID of the NAME=55 data to 5

Delete a row

 from where name='in ';

Clears a table, but does not delete

> TRUNCATE TABLE wangshaojun.tb1;

Specify the library name and table name

Delete a table

> drop table tb1;

Delete a library

> DROP database Wangshaojun;

LAMP 3.3 MySQL Common operation-1

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.