MySQL的链接,查看数据库,使用数据库,查看表

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| qq |
| test |
+--------------------+
5 rows in set (0.06 sec) mysql> use qq;
Database changed
mysql> desc qq;
ERROR 1146 (42S02): Table 'qq.qq' doesn't exist
mysql> 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 1
mysql> 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 1
mysql> 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 3
mysql> 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 1
mysql> 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 2
mysql> 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
-> \c
mysql>
mysql> insert into class(
-> \c
mysql> 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 1
mysql> 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 1
mysql> 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 2
mysql> 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: 0 mysql> select * from class;
+----+-------+--------+---------+---------+
| id | sname | gender | company | salary |
+----+-------+--------+---------+---------+
| 1 | 张三 | 男 | 百度 | 7000.00 |
| 2 | lizi | 男 | ibm | 7800.00 |
+----+-------+--------+---------+---------+
2 rows in set (0.02 sec)

MySQL的链接,查看数据库,使用数据库,查看表的更多相关文章

  1. mysql数据库中,查看当前支持的字符集有哪些?字符集默认的collation的名字?

    需求描述: mysql数据库支持很多字符集,那么如何查看当前的mysql版本中支持的或者说可用的字符集有什么呢? 操作过程: 1.使用show character set的方式获取当前版本中支持的字符 ...

  2. MySQL 如何查看及修改数据库引擎

    MySQL 如何查看及修改数据库引擎 1.查看mysql支持的引擎有哪些 show engines 结果,如图所示: 由上图可以看出,只有InnoDB是支持事务的 2.查看当前默认的引擎 show v ...

  3. mysql数据库创建、查看、修改、删除

    一.创建数据库 使用默认字符集 不指定字符集时,mysql使用默字符集,从mysql8.0开始,默认字符集改为utf8mb4 ,创建数据库的命令为create database 数据库名称. #创建数 ...

  4. mysql查看当前所有数据库中的表大小和元信息information_schema

    查看所有mysql数据库表和索引大小 mysql查看当前所有的数据库和索引大小 ,),' mb') as data_size, concat(,),'mb') as index_size from i ...

  5. 使用Android-Debug-Database 在浏览器中查看App的数据库

    使用参考:http://www.jianshu.com/p/89ccae3e590b源码地址:https://github.com/amitshekhariitbhu/Android-Debug-Da ...

  6. Android中如何使用命令行查看内嵌数据库SQLite3

    转载博客:http://www.linuxidc.com/Linux/2011-06/37135.htm 在上图中,除了最后一个红色的方框,其它方框都是adb shell下的命令. [1]在Andro ...

  7. mssql 用户只能查看授权的数据库

    问题背景:公司的一台数据库服务器上放在多个数据库,每个数据库都使用不同的登录名称,但在将项目文件发布到Ftp时,有些Ftp的信息是在客户那边的 一旦客户那边使用配置文件中的数据库信息连接到数据库他就能 ...

  8. Oracl数据库管理方面的资料(查询sga,查看oracle数据库名称sid,查看oracle数据库名称,查看表空间,修改表空间名称)

    显示Oracle sga相关信息: SQL> show sga Total System Global Area 105978600 bytes Fixed Size 453352 bytes ...

  9. mysql学习(2)-Navicat Premium 12 链接MySQL8.0.11数据库报2059错误

    Navicat Premium 12 链接MySQL8.0.11数据库报2059错误 1,问题现象 安装完MySQL8.0.11和Navicat Premium12后,我们会用Navicat去测试连接 ...

随机推荐

  1. From delegates to lambdas z

    I thought of naming this post “Evolution of lambdas in C#”, then I decided that wouldn’t be closest ...

  2. C# 线程更新UI

    最方便的用法: private void ViewMsg(string msg)        { /* control.Invoke(new SetControlTextDelegate((ct,  ...

  3. opencv保存选择图像中的区域(二)

    /* * ===================================================================================== * * Filen ...

  4. allegro

    ALLEGRO5的渲染部分低层使用了opengl或d3d加速.

  5. eclipse安装插件checkstyle

    最近听说了一个eclipse神器:checkstyle,可以帮助java开发人员规范代码,对我这种有代码洁癖的人来说,这有着不小的魔力啊,必然要安装试一试啊. 我最喜欢的安装方式是 输入一个安装网址, ...

  6. Spring Cloud介绍 Spring Cloud与Dubbo对比

    spring Cloud是一个基于Spring Boot实现的云应用开发工具,它为基于JVM的云应用开发中的配置管理.服务发现.断路器.智能路由.微代理.控制总线.全局锁.决策竞选.分布式会话和集群状 ...

  7. C#性能优化的一些技巧

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:C#性能优化的一些技巧.

  8. 通过Mouse Without Borders在多台机器上共享键盘鼠标

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:通过Mouse Without Borders在多台机器上共享键盘鼠标.

  9. XML 语法规则

    转摘自:http://www.w3school.com.cn/xml/xml_elements.asp XML 语法规则 XML 文档包含 XML 元素. XML 的语法规则很简单,且很有逻辑.这些规 ...

  10. 自己写的一个Js小插件

    这是效果图.上面一个过滤标签.下面弹出框,选择日,周,月.我的用途主要是报表查询的时候根据这3种类型来查询数据用的. 这里分享下代码. Js代码 (function ($) { $.extend($. ...