3.3-mysql Common Operations-1

Source: Internet
Author: User

Log in to MySQL


See which libraries are currently available

show databases;

Where library Tese is empty by default

Switch Library commands

Use Discuz or used MySQL is not added;

View current in that library

Mysql> Select Database ();

View Current User

Mysql> Select User ();

View current MySQL database version information

Mysql> select version ();

Several key knowledge of the database:

----------The field library contains the table, the table has rows, and there are fields in the row

See which tables are in the current library

Mysql> Show tables;

View a table pre_ucenter_vars, what are the descriptive information

mysql> desc Pre_ucenter_vars;

See how a table Pre_ucenter_vars is created, what its creation statement is

Mysql> Show CREATE TABLE pre_ucenter_vars\g; \g to make the layout beautiful

Create a custom Library

Create Database Wyp; To create a WYP library

Create a table in the WYP library Llzd

Use WYP switch to the WYP library

CREATE TABLE LLZD (' id ' int (4), ' name ' char (+) ') Engine=myisam DEFAULT CHARSET=GBK;

CREATE TABLE LLZD,ID length 4,name length 40, engine MyISAM default character set GBK

Create a table and insert a field in the Llzd table

INSERT into LLZD values (1, ' wuyaoping ');

1 represents the id ' wuyaoping ' for name, because it is char and must be enclosed in single quotation marks

Or insert only one field

mysql> INSERT INTO LLZD (' id ') values (2); Insert ID only

mysql> INSERT INTO Llzd (' name ') VALUES (' 55 '); Insert name only best Plus single quote

mysql> INSERT INTO Llzd (' name ', ' ID ') VALUES (' 66 ', 5); Flag can be reversed, same effect

View rows in a specified table

Mysql> select * from Llzd; Can see the information to 1,wuyaoping

In a table, update the fields in the table

mysql> Update llzd set id=4 where name = ' 66 '; after matching name, update ID

In a table, delete a row in the table

Mysql> Delete from Llzd where id=1;

or mysql> delete from llzd where name= ' wuyaoping ';

Empty the contents of a table

mysql> truncate TABLE wyp.llzd; Specify Library WYP and table Llzd

Delete a table

mysql> drop table Llzd;

Delete a library

mysql> drop Database Wyp;

3.3-mysql Common Operations-1

Related Article

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.