创建视图 CREATE VIEW VIEW_name AS SELECT empno, ename, sal, deptno FROM emp WHERE deptno = 10
删除视图 drop VIEW VIEW_name
查询视图 SELECT id, name, salary FROM VIEW_name
视图
SQL Server
select
a.name AS ViewName,
c.text AS CreateViewSQL
from
sys.views a
LEFT OUTER JOIN
dbo.syscomments c ON a.object_id = c.id
order by
a.name
MySQL
是否是视图 通过 table_type 字段是否为 VIEW 来区分的。
SELECT
table_name AS `视图名`,
table_type AS `类型`,
engine AS `引擎`,
table_comment AS `备注`
FROM
information_schema.tables
WHERE
table_schema = 'test' AND table_type = 'VIEW'
ORDER BY
table_name DESC
存储过程
SQL Server
select
pro.name AS ProcedureName,
c.text AS CreateProcedureSQL
from
sys.procedures pro LEFT OUTER JOIN
dbo.syscomments c ON pro.object_id = c.id
MySQL 里面,查存储过程的,我这里暂时没有。
sql语句要快1.不必要的列就不用查出来2作为查询的条件列设索引3.如果查询的表数据大于500万条数据,表创建之初就应该建立表分区,依据分表去查最最重要的是传输给前台页面的数据量尽量简化减少传输量,比如时间数据最好不传,自己规定个顺序,依据顺序前台生成对应的时间非要传可转为毫秒数去掉最后四个零(依据实际情况而定,因为时间只要求精确到分),用[]不用{}(key就不用传了,根据商量好的下标对应提取)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)