MySQL的連結,查看資料庫,使用資料庫,查看錶

來源:互聯網
上載者:User

標籤:

MySQL的連結,查看資料庫,使用資料庫,查看錶

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 an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to 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 | 李四    |+------+------+2 rows in set (0.01 sec)mysql> insert into stu values    -> (2,‘zhangsan‘);ERROR 1406 (22001): Data too long for column ‘name‘ at row 1mysql> insert into stu values    -> (2,‘zhangsan‘)    -> (3,‘zhan‘);ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘(3,‘zhan‘)‘ at line 3mysql> 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 || 李四    || zhan |+------+3 rows in set (0.00 sec)mysql> delete form where id=3;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘where id=3‘ at line 1mysql> delete from stu where id=3;Query OK, 0 rows affected (0.02 sec)mysql> select (name) from stu;+------+| name |+------+| lisi || 李四    || zhan |+------+3 rows in set (0.00 sec)mysql> select * from stu;+------+------+| id   | name |+------+------+|    1 | lisi || NULL | 李四    ||    2 | zhan |+------+------+3 rows in set (0.00 sec)mysql> delete from stu where id    -> id=null;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘id=null‘ at line 2mysql> 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 | 李四    |+------+------+2 rows in set (0.00 sec)mysql> insert into classs    -> /c    -> \cmysql> mysql> insert into class(    -> \cmysql> create table class(    -> id int primary key auto_increment,    -> sname varchar(10) not null default ‘‘,    -> gender char(1) not null default ‘‘,    -> company varchar(20) 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,‘張三‘,‘男‘,‘百度‘,7000);Query OK, 1 row affected (0.03 sec)mysql> show table from class;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘from class‘ at line 1mysql> select * form class;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘form class‘ at line 1mysql> select * from class;+----+-------+--------+---------+---------+| id | sname | gender | company | salary  |+----+-------+--------+---------+---------+|  1 | 張三      | 男       | 百度       | 7000.00 |+----+-------+--------+---------+---------+1 row in set (0.01 sec)mysql> insert into    -> (name,gender,company)    -> values    -> (‘lisi‘,‘男‘,‘ibm‘);ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘(name,gender,company)values(‘lisi‘,‘男‘,‘ibm‘)‘ at line 2mysql> insert into class    -> (name,gender,company)    -> values    -> (‘lisi‘,‘男‘,‘ibm‘)    -> ;ERROR 1054 (42S22): Unknown column ‘name‘ in ‘field list‘mysql> insert into class    -> (sname,gender,company)    -> values    -> (‘lizi‘,‘男‘,‘ibm‘);Query OK, 1 row affected (0.00 sec)mysql> select * from class;+----+-------+--------+---------+---------+| id | sname | gender | company | salary  |+----+-------+--------+---------+---------+|  1 | 張三      | 男       | 百度       | 7000.00 ||  2 | lizi  | 男       | 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 | 張三      | 男       | 百度       | 7000.00 ||  2 | lizi  | 男       | ibm     |    0.00 |+----+-------+--------+---------+---------+2 rows in set (0.00 sec)mysql> select company from class;+---------+| company |+---------+| 百度       || ibm     |+---------+2 rows in set (0.00 sec)mysql> select * from class where id=2;+----+-------+--------+---------+--------+| id | sname | gender | company | salary |+----+-------+--------+---------+--------+|  2 | lizi  | 男       | ibm     |   0.00 |+----+-------+--------+---------+--------+1 row in set (0.00 sec)mysql> #改,改哪張表,哪幾列, 哪幾行,改成什麼值。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 | 張三      | 男       | 百度       | 7000.00 ||  2 | lizi  | 男       | ibm     | 7800.00 |+----+-------+--------+---------+---------+2 rows in set (0.02 sec)

 

MySQL的連結,查看資料庫,使用資料庫,查看錶

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.