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. CSS——LESS

    去年就初次接触了LESS,并用他制作了一个Less.org的首页页面,但由于CSS的固有模式,没有让自己喜欢上他.由于前段时间学习bootstrap from twitter再次让我接触了这个Less ...

  2. apache开源项目--kylin

    Kylin 是一个开源的分布式的 OLAP 分析引擎,来自 eBay 公司开发,基于 Hadoop 提供 SQL 接口和 OLAP 接口,支持 TB 到 PB 级别的数据量. Kylin 是: 超级快 ...

  3. RESTLET开发实例(三)基于spring的REST服务

    http://www.lifeba.org/arch/restlet_spring_3.html 前面两篇文章,我们介绍了基于JAX-RS的REST服务以及Application的Rest服务.这里将 ...

  4. 使用Spring MVC 的表单控制器SimpleFormController

    以注册过程为例,我们可能会选择继承AbstractController来实现表单的显示,继承AbstractCommandController来实现表单的处理 ,这样是可行的,但必须要维护两个控制器 ...

  5. POJ 2406

    思路:由于题目要求的是最大值,因此从n开始向下查找,第一次出现的满足条件的那个数就是最大的,查找就可以结束,如果查找到1是仍未找到合适的值,则为1,就是说不是任何字符串的次方如abcd #includ ...

  6. .net软件自动化测试笔记(API-2)

    1.9获得测试运行时间如何获得测试运行的总时间设计:DateTime.Now属性记录测试开始运行时间,以及测试结束时间,用一个TimeSpan对象计算本次运行的总时间 DateTime starTim ...

  7. Android之parseSDKContent failed

    由于之前安装ADT之后就一直报parseSDKContent failed的错误,具体的信息为:java.lang.NullPointerException. 此问题的情况为在Eclipse下,And ...

  8. Ruby require 路径问题

    require 负责引用一个外部文件,可以省略".rb"字样. 如: require 'foo.bar' 等价于 require 'foo' 在Ruby中,同一目录下的文件, 如 ...

  9. nyoj重建二叉树(不真的建立)

      感觉c++很陌生啊 题目很简单,给你一棵二叉树的后序和中序序列,求出它的前序序列(So easy!). 输入 输入有多组数据(少于100组),以文件结尾结束.每组数据仅一行,包括两个字符串,中间用 ...

  10. [转载]DOS循环:bat/批处理for命令详解 (史上虽详尽的总结和说明~~)

    --本文来源于TTT BLOG: http://www.yoyotao.net/ttt/, 原文地址:http://www.yoyotao.net/ttt/post/139.html 前言: 虽然以前 ...