
查询一个数据库中的所有表sql语句是show
tables;
显示所有数据库的命令是:show
databases;要查看某个数据库先要进入数据库使用user
命令;进入数据库之后才能查询数据库中有哪些表。使用以下命令即可查出所有表:
show
tables;
扩展资料
mysql数据库的基本sql *** 作命令介绍:
1、显示当前数据库服务器中的数据库列表:mysql>
SHOW
DATABASES;
2、建立数据库:mysql>
CREATE
DATABASE
库名;
3、建立数据表:mysql>
USE
库名;mysql>
CREATE
TABLE
表名
(字段名
VARCHAR(20),
字
名
CHAR(1));
4、删除数据库:mysql>
DROP
DATABASE
库名;
5、删除数据表:mysql>
DROP
TABLE
表名;
6、将表中记录清空:mysql>
DELETE
FROM
表名;
7、往表中插入记录:mysql>
INSERT
INTO
表名
VALUES
("hyq","M");
8、更新表中数据:mysql->
UPDATE
表名
SET
字段名1='a',字段名2='b'
WHERE
字段名3='c';
9、用文本方式将数据装入数据表中:mysql>
load
data
local
infile
"d:/mysqltxt"
into
table
表名;
10、导入sql文件命令:mysql>
USE
数据库名;mysql>
source
d:/mysqlsql;
要点:left join,right join,inner join
首先有如下两个表:
Student:
ID(int) Name(nvarchar)
1 a
2 b
3 c
4 d
5 e
6 f
Quiz:
ID(int) score(int)
1 60
2 70
4 80
6 90
8 100
9 30
内连接:(inner join)包括连接表的匹配行
select StudentName,Quizscore from Quiz inner join Student on StudentID=QuizID
Name score
a 60
b 70
d 80
f 90
左连接:(left join)包括连接表匹配行以及左连接表的所有行
select StudentName,Quizscore from Student left join Quiz on StudentID=QuizID
Name score
a 60
b 70
c null
d 80
e null
f 90
右连接:(right join)结果包括连接表的匹配行以及右连接表的所有行
select StudentName,Quizscore from Student right join Quiz on StudentID=QuizID
Name score
a 60
b 70
d 80
f 90
null 100
null 30
当然,也可以看出左连接也可以写成右连接的形式:
select StudentName,Quizscore from Student right join Quiz on StudentID=QuizID等价于
select StudentName,Quizscore from Quiz left join Student on StudentID=QuizID
以上就是关于SQL语句查询数据库中所有记录全部的内容,包括:SQL语句查询数据库中所有记录、mysql数据库查询 *** 作、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)