MySQL links, viewing databases, working with databases, viewing tables

Source: Internet
Author: User

MySQL links, viewing databases, working with databases, viewing tables

Mysql> Show databases;+--------------------+| Database |+--------------------+| Information_schema | | MySQL | | Performance_schema | | QQ | | Test |+--------------------+5 rows in Set (0.06 sec) mysql> use qq;database changedmysql> desc QQ; ERROR 1146 (42S02): Table ' qq.qq ' doesn ' t existmysql> desc Table; Error 1064 (42000): You have a error in your SQL syntax;  Check the manual-corresponds to your MySQL server version for the right syntax-use near ' table ' at line 1mysql> Set name GBK; ERROR 1193 (HY000): Unknown system variable ' name ' mysql> set names GBK; Query OK, 0 rows Affected (0.00 sec) mysql> Show tables;+--------------+| TABLES_IN_QQ |+--------------+| Stu |+--------------+1 row in Set (0.01 sec) mysql> desc stu;+-------+------------+------+-----+---------+----- --+| Field | Type | Null | Key | Default | Extra |+-------+------------+------+-----+---------+-------+| ID | Int (11) | YES | |       NULL | || name | varchar (4) |     YES | |       NULL | |+-------+------------+------+-----+---------+-------+2 rows in Set (0.02 sec) mysql> SELECT * FROM stu;+------+----- -+| ID |    Name |+------+------+| 1 | Lisi | | NULL | John Doe |+------+------+2 rows in Set (0.01 sec) mysql> insert into Stu values, (2, ' Zhangsan '); ERROR 1406 (22001): Data too long for column ' name ' @ row 1mysql> insert into STU values---(2, ' Zhangsan ')-& Gt (3, ' Zhan '); Error 1064 (42000): You have a error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use-near ' (3, ' Zhan ') ' on line 3mysq l> INSERT into STU values---(2, ' Zhan '); Query OK, 1 row Affected (0.00 sec) mysql> Show tables;+--------------+| TABLES_IN_QQ |+--------------+| Stu |+--------------+1 row in Set (0.00 sec) mysql> Select (name) from stu;+------+| Name |+------+| Lisi | | John Doe | | Zhan |+------+3 rows in Set (0.00 sec) mysql> Delete form where id=3; Error 1064 (42000): You have a error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use near ' where id=3 ' at line 1mysq L> Delete from Stu where id=3; Query OK, 0 rows affected (0.02 sec) mysql> Select (name) from stu;+------+| Name |+------+| Lisi | | John Doe | | Zhan |+------+3 rows in Set (0.00 sec) mysql> SELECT * FROM stu;+------+------+| ID |    Name |+------+------+| 1 | Lisi | | NULL |    John Doe | | 2 | Zhan |+------+------+3 rows in Set (0.00 sec) mysql> Delete from Stu where id, id=null; Error 1064 (42000): You have a error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use-near ' id=null ' on line 2MYSQL&G T Delete from Stu where id=null; Query OK, 0 rows Affected (0.00 sec) mysql> Delete from Stu where id=null; Query OK, 0 rows Affected (0.00 sec) mysql> Delete from Stu where id= '; Query OK, 0 rows Affected (0.00 sec) mysql> Delete from Stu where id=2; Query OK, 1 row Affected (0.00 sec) mysql> SELECT * FROM stu;+------+------+| ID |    Name |+------+------+| 1 | Lisi | | NULL | John Doe |+------+------+2 rows in Set (0.00 sec) mysql> INSERT into CLASSS,/C-\cmysql> mysql> Inse RT into Class (\cmysql> Create TABLE class (ID int primary KEY auto_increment, sname varchar    (+) NOT NULL default ", Gender char (1) NOT NULL default", "Company varchar", "NOT null default", -Salary Decimal (6,2) NOT NULL default 0.00--) engine MyISAM charset UTF8; Query OK, 0 rows affected (0.08 sec) mysql> desc class;+---------+--------------+------+-----+---------+------------ ----+| Field | Type | Null | Key | Default | Extra |+---------+--------------+------+-----+---------+----------------+| ID | Int (11) | NO | PRI | NULL | auto_increment | | sname | varchar (10) |     NO |         |      |          || Gender | char (1) |     NO |         |                | || Company | varchar (20) |     NO |         |                | || Salary | Decimal (6,2) |     NO | |                0.00 |    |+---------+--------------+------+-----+---------+----------------+5 rows in Set (0.00 sec) mysql> insert INTO class Values---1, ' Zhang San ', ' Male ', ' Baidu ', 7000; Query OK, 1 row affected (0.03 sec) mysql> Show Table from class; Error 1064 (42000): You have a error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use near ' from class ' at line 1mysq L> select * Form class; Error 1064 (42000): You have a error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use near ' form class ' at line 1mysq L> SELECT * from class;+----+-------+--------+---------+---------+| ID | sname | Gender | Company |  Salary |+----+-------+--------+---------+---------+| 1 | Zhang San |Male | Baidu | 7000.00 |+----+-------+--------+---------+---------+1 row in Set (0.01 sec) mysql> insert INTO, name,gender,com pany), values---' Lisi ', ' Male ', ' IBM '; Error 1064 (42000): You have a error in your SQL syntax; Check the manual-corresponds to your MySQL server version for the right syntax-use-near ' (Name,gender,company) Valu Es (' Lisi ', ' Male ', ' IBM ') ' at line 2mysql> insert into Class (Name,gender,company), values---' Lisi ' , ' Male ', ' IBM '); ERROR 1054 (42S22): Unknown column ' name ' in ' field List ' mysql> insert into Class (Sname,gender,company)-& Gt Values--(' Lizi ', ' Male ', ' IBM '); Query OK, 1 row Affected (0.00 sec) mysql> SELECT * from class;+----+-------+--------+---------+---------+| ID | sname | Gender | Company |  Salary |+----+-------+--------+---------+---------+| 1 | Zhang San | Male | Baidu |  7000.00 | | 2 | Lizi | Male |    IBM | 0.00 |+----+-------+--------+---------+---------+2 rows in Set (0.00 sec) mysql> SELECT * from class where company; Empty set, 2 Warnings (0.00 sec) mysql> SELECT * from class;+----+-------+--------+---------+---------+| ID | sname | Gender | Company |  Salary |+----+-------+--------+---------+---------+| 1 | Zhang San | Male | Baidu |  7000.00 | | 2 | Lizi | Male |    IBM | 0.00 |+----+-------+--------+---------+---------+2 rows in Set (0.00 sec) mysql> Select Company from class;+---------+ | Company |+---------+| Baidu | | IBM |+---------+2 rows in Set (0.00 sec) mysql> SELECT * from class where id=2;+----+-------+--------+---------+---- ----+| ID | sname | Gender | Company |  Salary |+----+-------+--------+---------+--------+| 2 | Lizi | Male |   IBM | 0.00 |+----+-------+--------+---------+--------+1 row in Set (0.00 sec) mysql> #改, which table to change, which columns, which rows, to what value. Mysql> Update class, set salary=7800, where id=2; Query OK, 1 row affected (0.01 sec) Rows matched:1 changed:1 Warnings:0mysql> SELECT * from class;+----+-------+--------+---------+---------+| ID | sname | Gender | Company |  Salary |+----+-------+--------+---------+---------+| 1 | Zhang San | Male | Baidu |  7000.00 | | 2 | Lizi | Male | IBM | 7800.00 |+----+-------+--------+---------+---------+2 rows in Set (0.02 sec)

MySQL links, viewing databases, working with databases, viewing tables

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.