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去测试连接 ...
随机推荐
- 【转】can't find referenced method 'android.app.RemoteInput[] getRemoteInputs()' in class android.app.Notification$Action
原文网址:http://stackoverflow.com/questions/25508735/cant-find-referenced-method-android-app-remoteinput ...
- 使用C#调用Python脚本,带参数列表 z
static void Main(string[] args) { string[] strArr;//参数列表 string sArguments = @"Pythons.py" ...
- NPOI读取Excel案例
3.4用NPOI操作EXCEL--从Excel中抽取文本 我们知道,搜索引擎最擅长处理的就是文本,而Excel中的内容并不是以文本方式存储的.那么如果想要搜索引擎爬虫能够抓取到Excel中的内容是比较 ...
- BOM(浏览器对象模型)的一些内置对象总结
1.window对象 BOM的核心对象是window,它表示浏览器的一个实例,它也是ECMAScript规定的Globle对象,也就是说网页中任何一个对象都是在window这个对象里面的.如果有用到框 ...
- 【CSS3】Advanced3:Universal, Child, and Adjacent Selectors
1.Universal selectors eg:#target*{ } 2.Child selectors < something immediately nested within some ...
- 活用maven使web.xml可以用maven变量
活用maven使web.xml可以用maven变量 废话不多说,直接上代码 <build> <finalName>${finalWarName}</finalName&g ...
- 查看目标文件是否是以-fPIC编译的, ar 打包命令将多个静态库打包到一个里面
readelf --relocs foo.o | egrep '(GOT|PLT|JU?MP_SLOT)' 上句大多数时候(和平台有关)可以正确判断是否是以fPIC选项编译的,如果输出为空,基本可以表 ...
- ios中的容器类 ViewController
https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/AboutViewContro ...
- X265编码效率仍然低
本次测试软件环境:Intel Celeron双核 2.60 Ghz CPU; 4GB 内存:安装 Ubuntu 13.04 hzsx@hzsx-server:~$ lsb_release -a No ...
- 详细讲解Hadoop源码阅读工程(以hadoop-2.6.0-src.tar.gz和hadoop-2.6.0-cdh5.4.5-src.tar.gz为代表)
首先,说的是,本人到现在为止,已经玩过. 对于,这样的软件,博友,可以去看我博客的相关博文.在此,不一一赘述! Eclipse *版本 Eclipse *下载 Jd ...