标签:info 主键 双引号 相同 创建 server 查询语句 exe 一个
https://shimo.im/docs/xCJwTcPCjT3k8pjD/
select sum(表记录数) as "11111" --数字别名用双引号表示,英文、汉字可以不用引号 from( SELECT COUNT(*) as 表记录数 FROM [l_jyzx_sj2019].dbo.l_sy --数据库、dbo、表,三个当中必须有一个要加中括号,否则会报错,下面语法一样。 union all select COUNT(*) FROM [l_jyzx_sj2018].[dbo].[l_sy] --这个是完整版。 union all select COUNT(*) FROM [l_jyzx_sj2017].dbo.l_sy ) as 聚合表别名 --聚合出来的表要起个别名,否则会报语法错误。
SELECT nd AS ‘年度‘, COUNT(nd) AS ‘人数‘ FROM [bdz].[dbo].[bdz] GROUP BY nd HAVING COUNT(nd) > 380000
SELECT COLLATIONPROPERTY(‘Chinese_PRC_Stroke_CI_AI_KS_WS‘, ‘CodePage‘) --数据库编码查询
4.命令4:
select * FROM [l_jyzx_sj2018].[dbo].[l_sy] /*查询数据库[l_jyzx_sj2018]中表[dbo].[l_sy] 的所有字段。*/
mysql 语句: SELECT CONCAT(stu_id, ‘#‘, stu_name) FROM student
https://www.cnblogs.com/mayytest1202/p/10330208.html
https://baike.baidu.com/item/concat%28%29/13473511?fr=aladdin
select into from
select *(查询出来的结果) into newtable(新的表名)from where (后续条件)
insert into select
insert into (准备好的表) select *(或者取用自己想要的结构)from 表名 where 各种条件
实例:
create table table_name_new as select * from table_name_old
create table table_name_new as select * from table_name_old where 1=2;
create table table_name_new like table_name_old
insert into table_name_new select * from table_name_old
insert into table_name_new(column1,column2...) select column1,column2... from table_name_old
方法一:命令
方法二:菜单
https://blog.csdn.net/a22698488/article/details/90373122
https://www.cnblogs.com/cuozhixu/archive/2018/11/05/9909310.html
desc stu1 //查看表stu的表表结构
【MySQL】stu表按降序排列(默认升序),并插入限定范围记录到stu1
insert into `stu1` select * FROM `stu` ORDER BY `id` DESC LIMIT 100 (或者0,100) //前100条记录复制到表stu(表面和字段用单引号或无引号均可) insert into `6`(sid,xm) select sf,cs from `stu5` ORDER BY `id` DESC limit 2,3 //表stu5(注意是从第二条记录开始索引,不包括第二条)第3~5三条记录的字段sf,cs值插入(追加)到表stu的sid,xm字段列(不一定要是同名字段)
CREATE TABLE stu4 SELECT * FROM stu2 CREATE TABLE stu6 AS (SELECT * FROM stu3) //同上一句作用一样 CREATE TABLE stu8 AS (SELECT id, xm FROM stu3) //只复制id,xm两个字段 CREATE TABLE stu7 AS (SELECT ID AS SID,xm AS xm1,bh AS bh1 FROM `stu1`) //复制ID,xm,bh 三个字段,并对这些字段进行了重命名 CREATE TABLE stu9 SELECT ID AS SID,xm AS xm1,bh AS bh1 FROM `stu1` //作用同上,不用as也可以
CREATE TABLE stu3 LIKE stu
create table stu6 like stu; instert into stu6 SELECT * FROM stu2
SQL显示查询结果的前100条
MYSQL:
select * from tbl limit 100;
ORACLE:
select * from tbl where rownum<=100;
SQL SERVER:
select top 100 * from tbl
SYBASE:
SET ROWCOUNT N GOSELECT * FROM TABLE1
select * from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where REFERENCED_TABLE_NAME=‘stu2‘ alter table 表名 drop foreign key 外键约束名称 //删除外键 alter table stu2 drop foreign key 编号
show create table stu5 //查看表结构
标签:info 主键 双引号 相同 创建 server 查询语句 exe 一个
原文地址:https://www.cnblogs.com/al88/p/12444096.html