MySQL的链接,查看数据库,使用数据库,查看表
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的链接,查看数据库,使用数据库,查看表的更多相关文章
- mysql数据库中,查看当前支持的字符集有哪些?字符集默认的collation的名字?
需求描述: mysql数据库支持很多字符集,那么如何查看当前的mysql版本中支持的或者说可用的字符集有什么呢? 操作过程: 1.使用show character set的方式获取当前版本中支持的字符 ...
- MySQL 如何查看及修改数据库引擎
MySQL 如何查看及修改数据库引擎 1.查看mysql支持的引擎有哪些 show engines 结果,如图所示: 由上图可以看出,只有InnoDB是支持事务的 2.查看当前默认的引擎 show v ...
- mysql数据库创建、查看、修改、删除
一.创建数据库 使用默认字符集 不指定字符集时,mysql使用默字符集,从mysql8.0开始,默认字符集改为utf8mb4 ,创建数据库的命令为create database 数据库名称. #创建数 ...
- mysql查看当前所有数据库中的表大小和元信息information_schema
查看所有mysql数据库表和索引大小 mysql查看当前所有的数据库和索引大小 ,),' mb') as data_size, concat(,),'mb') as index_size from i ...
- 使用Android-Debug-Database 在浏览器中查看App的数据库
使用参考:http://www.jianshu.com/p/89ccae3e590b源码地址:https://github.com/amitshekhariitbhu/Android-Debug-Da ...
- Android中如何使用命令行查看内嵌数据库SQLite3
转载博客:http://www.linuxidc.com/Linux/2011-06/37135.htm 在上图中,除了最后一个红色的方框,其它方框都是adb shell下的命令. [1]在Andro ...
- mssql 用户只能查看授权的数据库
问题背景:公司的一台数据库服务器上放在多个数据库,每个数据库都使用不同的登录名称,但在将项目文件发布到Ftp时,有些Ftp的信息是在客户那边的 一旦客户那边使用配置文件中的数据库信息连接到数据库他就能 ...
- Oracl数据库管理方面的资料(查询sga,查看oracle数据库名称sid,查看oracle数据库名称,查看表空间,修改表空间名称)
显示Oracle sga相关信息: SQL> show sga Total System Global Area 105978600 bytes Fixed Size 453352 bytes ...
- mysql学习(2)-Navicat Premium 12 链接MySQL8.0.11数据库报2059错误
Navicat Premium 12 链接MySQL8.0.11数据库报2059错误 1,问题现象 安装完MySQL8.0.11和Navicat Premium12后,我们会用Navicat去测试连接 ...
随机推荐
- Oracle to_char格式化函数
转:http://www.cnblogs.com/reborter/archive/2008/11/28/1343195.html Postgres 格式化函数提供一套有效的工具用于把各种数据类型(日 ...
- Go语言程序的状态监控 via 达达
Go语言程序的状态监控 Go是很实在的编程语言,从一开始就提供了很详细的运行状态信息.产品上线后的调优和排查疑难杂症都得靠这些状态信息.这边总结一些我们项目里用到的状态监控手段. pprof Go自带 ...
- CONTAINING_RECORD 宏
Windows中提供了一个宏 #define CONTAINING_RECORD (address, type, field ) ((type *)( \ (PCHAR)(address ) - \ ...
- UVA 11754 Code Feat 中国剩余定理+暴力
lrj白书例题,真好 #include <stdio.h> #include <iostream> #include <vector> #include <m ...
- QTP常见问题解决方法(一)
1.对脚本的运行速度进行设置 TOOLS->OPTIONS->RUN->RUN MODE 设置就可以了:一般可以设置为500或者1000值,也就是毫秒: QTP 12.0版本: TO ...
- 用FSM写Case,玩过没?
一.引言 测试工程师小新一是一名安卓客户端测试工程师,对于安卓客户端的功能测试.自动化测试和性能测试方面都有着非常丰富的经验.最近小新一被通知负责某二手交易APP的功能测试,在初步了解了该APP后,小 ...
- Api项目压力测试知识荟萃
并发用户.在线用户和注册用户以及彼此之间的换算方法(估算模型).系统的最大并发用户数根据注册用户数来获得,换算方法一般是注册总人数的5%-20%之间:系统的并发数根据在线人数来获得,换算方法一般是在3 ...
- HW5.9
public class Solution { public static void main(String[] args) { System.out.printf("%s\t%s\t%s\ ...
- Call Hierarchy(方法调用层次)
在VS2010中的一项新功能:Call Hierarchy窗口,它可以审查代码,确定方法在哪里调用,以及它们与其他方法的关系. 打开一个类文件,找有方法体实现代码的方法,右键选择View Call H ...
- mac编程的debug工具
Chisel是一个加强LLDB调试能力的小插件.主要特点在于辅助界面开发调试时在控制台以尽可能直观的方式查看界面的元素和情况.为我们梳理视图,控制器以及类关系层级.以及一些临时的界面调试变动进行快捷响 ...