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去测试连接 ...
随机推荐
- NuGet -- 如何创建及发布自己的程序包
STEP 1:在NuGet上注册并获取API Key 首先,你需要在NuGet(https://www.nuget.org/)上注册一个新的账号,然后在My Account页面,获取一个API ...
- htmlparser源码简单分析
Htmlparser源代码分析 一.根目录下的类 1.Attribute.java 属性类,四个field:mName,mAssignment,mValue,mQuote; 空白标签时:mName=n ...
- 两种应该掌握的排序方法--------2.quick Sort
介绍 http://zh.wikipedia.org/wiki/%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F 用些里面的c++ 实现,感觉这个空间复杂度比较小.还挺好 in ...
- NGINX(二)内存池
ngxin中为了加快内存分配的速度,引入了内存池, 大块申请, 减少分配次数, 小块分割, 极大的提高了内存申请速度, 另外一个用途就是省去了很多内存管理的任务,因为这里没有提供内存释放的功能,也就是 ...
- JZ2440开发笔记(2)——minicom的安装和配置使用【转】
一.安装配置minicom 1.安装minicom lingd@ubuntu:~$ sudo apt-get install minicom 2.配置minicom lingd@ubuntu:~$ s ...
- jquery,javascript常用
1.jquery ajax应用 ajax方式 $.ajax({ url: 'stat.php', type: 'POST', data:{Name:"keyun"}, dataTy ...
- linux find用法总结
前言:我们为什么要学会使用find命令? 转自:http://blog.chinaunix.net/uid-24648486-id-2998767.html 每一种操作系统都有成千上万的文件组成,对于 ...
- codeforces 664A Complicated GCD
水题..[a,b]区间数的最大公约数. a==b输出a 否则输出1 #include<cstdio> #include<cstring> #include<iostrea ...
- php学习小记2 类与对象
php类的一些特性: 1. 伪变量$this.$this是一个到主叫对象的引用.取值:该方法所从属的对象,可能是另外的对象(前提,当该方法被静态调用时).$this变量存在于一个类的非静态方法中,在静 ...
- Solution for When browse http://xxx/ReportServer Show Error (rsAccessDenied)
Issue: Reporting Services Error The permissions granted to user 'IDEAAM\William' are insufficient fo ...