Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文章中的代码显示出现问题 #2227

Closed
Meli55a opened this issue Oct 26, 2016 · 16 comments
Closed

文章中的代码显示出现问题 #2227

Meli55a opened this issue Oct 26, 2016 · 16 comments

Comments

@Meli55a
Copy link

Meli55a commented Oct 26, 2016

Node version

v4.6.0

Plugin version(npm ls --depth 0)

hexo-site@0.0.0 E:\GitHub\hexo
├── abab@1.0.3
├── abbrev@1.0.9
├── accepts@1.3.3
├── acorn@2.7.0
├── acorn-globals@1.0.9
├── amdefine@1.0.0
├── ansi-regex@2.0.0
├── ansi-styles@2.2.1
├── anymatch@1.3.0
├── archy@1.0.0
├── argparse@1.0.9
├── arr-diff@2.0.0
├── arr-flatten@1.0.1
├── array-unique@0.2.1
├── arrify@1.0.1
├── asap@2.0.5
├── asn1@0.2.3
├── assert-plus@0.2.0
├── async@0.2.10
├── async-each@1.0.1
├── asynckit@0.4.0
├── aws-sign2@0.6.0
├── aws4@1.5.0
├── balanced-match@0.4.2
├── basic-auth@1.0.4
├── bcrypt-pbkdf@1.0.0
├── binary-extensions@1.7.0
├── bl@1.1.2
├── bluebird@3.4.6
├── boolbase@1.0.0
├── boom@2.10.1
├── brace-expansion@1.1.6
├── braces@1.8.5
├── browser-fingerprint@0.0.1
├── buffer-shims@1.0.0 extraneous
├── bunyan@1.8.1
├── bytes@2.3.0
├── camel-case@3.0.0
├── camelcase@2.1.1
├── caseless@0.11.0
├── chalk@1.1.3
├── cheerio@0.20.0
├── chokidar@1.6.1
├── cliui@3.2.0
├── code-point-at@1.0.1
├── combined-stream@1.0.5
├── commander@2.9.0
├── compressible@2.0.8
├── compression@1.6.2
├── concat-map@0.0.1
├── connect@3.5.0
├── core-js@1.2.7
├── core-util-is@1.0.2
├── cross-spawn@4.0.2
├── cryptiles@2.0.5
├── css-parse@1.7.0
├── css-select@1.2.0
├── css-what@2.1.0
├── cssom@0.3.1
├── cssstyle@0.2.37
├── cuid@1.3.8
├── dashdash@1.14.0
├── debug@2.2.0
├── decamelize@1.2.0
├── deep-is@0.1.3
├── delayed-stream@1.0.0
├── depd@1.1.0
├── destroy@1.0.4
├── dom-serializer@0.1.0
├── domelementtype@1.3.0
├── domhandler@2.3.0
├── domutils@1.5.1
├── dtrace-provider@0.6.0
├── ecc-jsbn@0.1.1
├── ee-first@1.1.1
├── ejs@1.0.0
├── encodeurl@1.0.1
├── entities@1.1.1
├── escape-html@1.0.3
├── escape-string-regexp@1.0.5
├── escodegen@1.8.1
├── esprima@2.7.3
├── estraverse@1.9.3
├── esutils@2.0.2
├── etag@1.7.0
├── expand-brackets@0.1.5
├── expand-range@1.8.2
├── extend@3.0.0
├── extglob@0.3.2
├── extsprintf@1.0.2
├── fast-levenshtein@2.0.5
├── filename-regex@2.0.0
├── fill-range@2.2.3
├── finalhandler@0.5.0
├── for-in@0.1.6
├── for-own@0.1.4
├── forever-agent@0.6.1
├── form-data@2.0.0
├── fresh@0.3.0
├── fs.realpath@1.0.0 extraneous
├── generate-function@2.0.0
├── generate-object-property@1.2.0
├── get-stdin@4.0.1
├── getpass@0.1.6
├── glob@6.0.4
├── glob-base@0.3.0
├── glob-parent@2.0.0
├── graceful-fs@4.1.9
├── graceful-readlink@1.0.1
├── har-validator@2.0.6
├── has-ansi@2.0.0
├── hawk@3.1.3
├── hexo@3.2.2
├── hexo-abbrlink@2.0.4
├── hexo-autonofollow@1.0.0
├── hexo-beautify@1.0.2
├── hexo-deployer-git@0.2.0
├── hexo-deployer-heroku@0.1.1
├── hexo-deployer-openshift@0.1.1
├── hexo-deployer-rsync@0.1.2
├── hexo-front-matter@0.2.3
├── hexo-fs@0.1.6
├── hexo-generator-archive@0.1.4
├── hexo-generator-category@0.1.3
├── hexo-generator-feed@1.2.0
├── hexo-generator-index@0.2.0
├── hexo-generator-sitemap@1.1.2
├── hexo-generator-tag@0.2.0
├── hexo-i18n@0.2.1
├── hexo-log@0.1.2
├── hexo-pagination@0.0.2
├── hexo-renderer-ejs@0.2.0
├── hexo-renderer-marked@0.2.11
├── hexo-renderer-stylus@0.3.1
├── hexo-server@0.2.0
├── hexo-util@0.6.0
├── highlight.js@9.7.0
├── hoek@2.16.3
├── html-entities@1.2.0
├── htmlparser2@3.8.3
├── http-errors@1.5.0
├── http-signature@1.1.1
├── inflight@1.0.6
├── inherits@2.0.3
├── invert-kv@1.0.0
├── is-binary-path@1.0.1
├── is-buffer@1.1.4
├── is-dotfile@1.0.2
├── is-equal-shallow@0.1.3
├── is-extendable@0.1.1
├── is-extglob@1.0.0
├── is-fullwidth-code-point@1.0.0
├── is-glob@2.0.1
├── is-my-json-valid@2.15.0
├── is-number@2.1.0
├── is-plain-object@2.0.1
├── is-posix-bracket@0.1.1
├── is-primitive@2.0.0
├── is-property@1.0.2
├── is-typedarray@1.0.0
├── isarray@0.0.1
├── isexe@1.1.2
├── isobject@2.1.0
├── isstream@0.1.2
├── jodid25519@1.0.2
├── js-yaml@3.6.1
├── jsbn@0.1.0
├── jsdom@7.2.2
├── json-schema@0.2.3
├── json-stringify-safe@5.0.1
├── jsonparse@1.2.0
├── jsonpointer@4.0.0
├── JSONStream@1.2.1
├── jsprim@1.3.1
├── kind-of@3.0.4
├── lcid@1.0.0
├── levn@0.3.0
├── lodash@4.16.4
├── lower-case@1.1.3
├── lru-cache@4.0.1
├── markdown@0.5.0
├── marked@0.3.6
├── micromatch@2.3.11
├── mime@1.3.4
├── mime-db@1.24.0
├── mime-types@2.1.12
├── minimatch@3.0.3
├── minimist@1.2.0
├── mkdirp@0.5.1
├── moment@2.13.0
├── moment-timezone@0.5.6
├── morgan@1.7.0
├── ms@0.7.1
├── mv@2.1.1
├── nan@2.4.0
├── ncp@2.0.0
├── negotiator@0.6.1
├── nib@1.1.2
├── no-case@2.3.0
├── node-fingerprint@0.0.2
├── node-uuid@1.4.7
├── nopt@2.1.2
├── normalize-path@2.0.1
├── nth-check@1.0.1
├── number-is-nan@1.0.1
├── nunjucks@2.5.2
├── nwmatcher@1.3.8
├── oauth-sign@0.8.2
├── object-assign@4.1.0
├── object.omit@2.0.0
├── on-finished@2.3.0
├── on-headers@1.0.1
├── once@1.4.0
├── opn@4.0.2
├── optimist@0.6.1
├── optionator@0.8.2
├── os-homedir@1.0.2
├── os-locale@1.4.0
├── parse-glob@3.0.4
├── parse5@1.5.1
├── parseurl@1.3.1
├── path-is-absolute@1.0.1
├── pinkie@2.0.4
├── pinkie-promise@2.0.1
├── prelude-ls@1.1.2
├── preserve@0.2.0
├── pretty-hrtime@1.0.2
├── process-nextick-args@1.0.7 extraneous
├── pseudomap@1.0.2
├── qs@6.2.1
├── randomatic@1.1.5
├── range-parser@1.2.0
├── readable-stream@1.1.14
├── readdirp@2.1.0
├── regex-cache@0.4.3
├── repeat-element@1.1.2
├── repeat-string@1.5.4
├── request@2.75.0
├── rimraf@2.4.5
├── safe-json-stringify@1.0.3
├── sax@1.2.1
├── send@0.14.1
├── serve-static@1.11.1
├── set-immediate-shim@1.0.1
├── setprototypeof@1.0.1
├── sigmund@1.0.1 extraneous
├── sntp@1.0.9
├── source-map@0.2.0
├── sprintf-js@1.0.3
├── sshpk@1.10.1
├── statuses@1.3.0
├── string-width@1.0.2
├── string_decoder@0.10.31
├── stringstream@0.0.5
├── strip-ansi@3.0.1
├── strip-indent@1.0.1
├── striptags@2.1.1
├── stylus@0.53.0
├── supports-color@2.0.0
├── swig@1.4.2
├── swig-extras@0.0.1
├── symbol-tree@3.1.4
├── text-table@0.2.0
├── through@2.3.8
├── tildify@1.2.0
├── titlecase@1.1.2
├── tough-cookie@2.3.1
├── tr46@0.0.3
├── tunnel-agent@0.4.3
├── tweetnacl@0.14.3
├── type-check@0.3.2
├── uglify-js@2.4.24
├── uglify-to-browserify@1.0.2
├── unpipe@1.0.0
├── upper-case@1.1.3
├── util-deprecate@1.0.2 extraneous
├── utils-merge@1.0.0
├── vary@1.1.0
├── verror@1.3.6
├── warehouse@2.2.0
├── webidl-conversions@2.0.1
├── whatwg-url-compat@0.6.5
├── which@1.2.11
├── window-size@0.1.4
├── wordwrap@1.0.0
├── wrap-ansi@2.0.0
├── wrappy@1.0.2
├── xml-name-validator@2.0.1
├── xtend@4.0.1
├── y18n@3.2.1
├── yallist@2.0.0
└── yargs@3.32.0


## For BUG

- 重装系统后重新配置了 hexo, 发现文章中的代码显示出现问题,如下图:

![qq 20161026193228](https://cloud.githubusercontent.com/assets/15644400/19729950/3928048c-9bcb-11e6-943d-6e50dc1889e7.png)
@NoahDragon
Copy link
Member

是网页上这么显示么?能否给个链接?

@ghost
Copy link

ghost commented Oct 26, 2016

我想看看自己的用户名

@Meli55a
Copy link
Author

Meli55a commented Oct 26, 2016

我的博客是:wncbl.cn, 看这篇文章:http://wncbl.cn/posts/947ac39b/

@NoahDragon
Copy link
Member

我怀疑是CSS style的问题。能贴下MD文件么?

@Meli55a
Copy link
Author

Meli55a commented Oct 27, 2016

非常感谢您的关注!
我把事情经过详细说一下,然后再贴 MD。
上周重装系统,我的系统是 win10,在重装的时候我备份了网站和主题的配置文件。
重装后,先配置 git,由于我对git不熟(大菜逼一枚),就安装了 github for desktop,但由于下载速度非常慢,加了host也没用,所以就找了一个 离线安装包,然后一路配置过来。
期间遇到过一些问题,像什么 ssh 公钥啊,还有一个就是 linux 和 windows 换行符不同(用 github for desktop 自带的 gitshell),但用 gitbash 就没有问题。由于我是双线部署的,国内的就放到 coding.net,但忘了那玩意儿不是及时生效的,我就以为出了问题,不停的删了重来,结果第二天自己好了。
我用的是Next主题,除了主题配置文件,其实全是重新下载的,而且“.deploy_git”文件也是重新生成的,所以问题应该不在主题这边。
一个比较重要点就是,我在重新部署时,在如下部分卡住好长时间:

INFO  Generated: vendors/fancybox/source/helpers/jquery.fancybox-media.js
INFO  Generated: vendors/fancybox/source/helpers/jquery.fancybox-thumbs.css
INFO  Generated: vendors/fancybox/source/helpers/jquery.fancybox-thumbs.js
INFO  Generated: vendors/ua-parser-js/dist/ua-parser.min.js
INFO  Generated: vendors/fastclick/lib/fastclick.js
INFO  Generated: vendors/font-awesome/css/font-awesome.min.css
INFO  Generated: vendors/font-awesome/css/font-awesome.css
INFO  Generated: vendors/fancybox/source/jquery.fancybox.js
...

具体的位置当时没有截图,我等了好长时间一直没动静,我就直接把窗口关了,所以我怀疑是不是哪部分的缓存导致的。MD文件都是之前备份的,配置好后直接放到 “_posts”文件夹下的。

以下是MD文件原文:

---
title: SQL server 常用命令
categories: 编程
tags:
  - SQL Server
  - 常用命令
abbrlink: 947ac39b
date: 2016-09-23 22:52:31
---

> 花了几天的时间,将《SQL必知必会(第4版)》过了一遍,一本非常适合 SQL 入门的一本书,没有废话,直奔主题,全面的介绍了 SQL 必须掌握的知识,实例为辅,有种相见恨晚的感觉,为了加深印象,搜罗了一篇 SQL Server 常用命令。

先放上《SQL必知必会(第4版)》的电子书,PDF + MOBI格式电子书 + 示例数据库 sql 语句 [**传送门**](https://yunpan.cn/ckXzpBRrnPeis)  访问密码:  **` 89bf`**

## 基础命令

### 数据库的创建与删除 

`` `SQL
  CREATE DATABASE db1;  -- 创建数据库db1

  DROP DATABASE db1;    -- 删除数据库db1
`` `

### 数据库的创建与删除 

`` `SQL
  CREATE TABLE t1(    -- 创建数据表 t1, t1 包含两个字段
  col1    varchar(100),
  col2    int
  );

  DROP TABLE t1;    -- 删除数据表 t1 
`` `
<!-- more -->
### 创建两表之间的外键关联

`` `SQL
  CREATE TABLE t2(    -- 创建主表
    t2_c1    char(8)    PRIMARY KEY,    -- 定义主键
    t2_c2    int
  );

  CREATE TABLE t3(
    t3_c1    char(8),
    t3_c2    int,
    FOREING KEY(t3_c1) REFERENCES t2(t2_c1)    -- 定义外键
  );

  DROP TABLE t3, t2;    -- t3 应先于 t2 被删除

`` `

### 索引的创建与删除

`` `SQL
  CREATE INDEX index1 ON t1(col1);    -- 创建非聚集索引 index1

  DROP INDEX index1 ON t1;    -- 删除非聚集索引 index1
`` `

### 视图的创建与删除

`` `SQL
  CREATE VIEW view1 AS  SELECT * FROM t1;   -- 创建视图 view1

  DROP VIEW view1;    -- 删除视图 view1  
`` `

### 超级用户的创建与删除

`` `SQL
  CREATE LOGIN log1   -- 创建名为log1的登录 
  WITH PASSWORD = "123456",   -- 密码为 123456
  DEFAULT_DATABASE = db1;   -- 默认数据库为 db1
  GO
  EXEC sp_addrolemember "log1", "sysadmin";    -- 赋最高权限
  GO

  DROP LOGIN log1;    -- 删除登录 log1
`` `

### 数据库用户的创建、授权与删除

`` `SQL
  CREATE LOGIN mylog WITH PASSWORD = "123456";      -- 先创建一个登录
  DEFAULT_DATABASE = db1;
  GO
  USE db1;
  GO
  CREATE USER user1 FOR LOGIN mylog;    -- user依赖于mylog
  GO
  GRANT CREATE TABLE, CREATE VIEW, CREATE PROCEDURE, ALTER ANY SCHEMA TO user1;   -- 授权
  GO

  DROP USER user1;    -- 删除用户 user1
  DROP LOGIN mylog;   -- 删除登录 mylog

`` `

### 数据库的备份与还原

`` `SQL
  USE master;
  GO
  ALTER DATABASE db1 SET RECOVERY SIMPLE;   -- 切换到简单恢复模式下
  GO
  BACKUP DATABASE db1   -- 将数据库 db1 完整备份到文件
  db1_disk.bak  -- 备份文件的名称
  TO DISK = "D:\Backup\db1_disk.bak"    -- 设置备份文件存放路径
  WITH FORMAT;
-------------------------------------------------------------
  USE master;
  GO
  EXEC sp_addumpdevice 'disk', 'db1_simple', 'D:\Backup\db1_disk.bak';
  GO
  RESTORE DATABASE db1    -- 利用备份文件db1_disk.bak完整还原 db1
  FROM db1_simple;
`` `

### 数据库的分享与附加

`` `SQL
  USE master;
  GO
  EXEC sp_detach_db 'db1', NULL, 'true';    -- 分离数据库

  -- 利用分离得到的 dbl.mdf 进行附加
  DECLARE @data_path navrchar(256);
  SET @data_path = 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\';
  EXEC ('CREATE DATABASE db1 
      ON (FILENAME = '''+ @data_path + 'db1.mdf'')
      FOR ATTACH');
  GO
`` `

### 存储过程的创建、调用和删除

`` `SQL
  CREATE PROCEDURE MyPro    -- 定义带两个参数的存储过程
    @min_avgrade numeric(3,1),
    @max_avgrade numeric(3,1)
  AS
    SELECT s_no,s_name,s_sex,s_avgrade,s_dept
    FROM student
    WHERE s_avgrade>=@min_avgrade AND s_avgrade<=@max_avgrade;
    ----------------------------------------------------------
    EXEC MyPro 50,88.8;   -- 调用存储过程
    ----------------------------------------------------------
    DROP PROCEDURE MyPro    -- 删除存储过程
`` `

### 触发器的创建、应用和删除

`` `SQL
  CREATE TRIGGER MyTrigger ON t1    -- 创建触发器
  AFTER DELETE
  AS
  BEGIN
  PRINT '有人删除表t1 中的数据!'
  END
  --------------------------------------------------
  -- 当执行 DELETE 语句时,该触发器被触发,如:
  DELETE FROM t1;
  --------------------------------------------------
  DROP TRIGGER MyTrigger;   -- 删除触发器
`` `

### 游标的创建、应用和删除

`` `SQL
  DECLARE MyCursor    -- 创建游标
  STATIC
  FOR SELECT col1 FROM t1;
  OPEN MyCursor;
  DECLARE @RowCount Integer, @i Integer, @col varchar(100);
  SET @i=0
  SET @RowCount = @@CURSOR_ROWS
  WHILE @i<@RowCount
  BEGIN
  FETCH NEXT FROM MyCursor    -- 将游标中的数据逐一输出
  INTO @col;
  PRINT @col;
  SET @i=@i+1
  END
  CLOSE MyCursor;
  DEALLOCATE MyCursor;    -- 删除游标
`` `

### 查看服务器上所有的数据库

`` `SQL
  SELECT *
  FROM sys.databases
  ORDER BY name
`` `

### 查看数据库中所有的数据表

`` `SQL
  USE db1;    -- 查询数据库 db1 中包含的所有数据库
  SELECT * FROM sys.tables;
`` `

### 查看数据表的结构

`` `SQL
  SELECT a.name 字段名, b.name 字段, a.max_length 字段长度
  FROM sys.all_columns as a
  JOIN sys.types as b
  ON a.system_type_id = b.system_type_id
  WHERE object_id = object_id('t1');
`` `

### 向数据表插入数据

`` `SQL
  INSERT INTO t1 VALUES('庆祝建国六十周年!', 60);   -- 向表t1插入数据  
  INSERT INTO t1 VALUES('北京奥运!', 29); 
  INSERT INTO t1 VALUES('上海世博会!', 51);
`` `

### 更新表中的数据

`` `SQL
  UPDATE t1
  SET col1 = '庆祝中华人民共和国建国六十周年!'
  WHERE col2=60;
`` `

### 删除表中的数据

`` `SQL
  DELETE FROM t1
  WHERE col2=29;
`` `

### 降序、有条件查询

`` `SQL
  SELECT col1, col2
  FROM t1
  WHERE col2 > 50
  ORDER BY col2 DESC
`` `

### 等值连接查询

`` `SQL
  SELECT t2.t2_c2, t2.t2_c2, t3.t3_c2
  FROM t2
  INNER JOIN t3
  ON (t2.t2_c1 = t3.t3_c1);
`` `

### 左外连接查询

`` `SQL
  SELECT t2.t2_c1, t2.t2_c2, t3.t3_c2
  FROM t2
  LEFT JOIN t3
  ON(t2.t2_c1 = t3.t3_c1);
`` `

### 右外连接查询

`` `SQL
  SELECT t2.t2_c1, t2.t2_c2, t3.t3_c2 
  FROM t2  
  RIGHT JOIN t3  
  ON(t2.t2_c1 = t3.t3_c1);
`` `

### 全外连接查询

`` `SQL
  SELECT t2.t2_c1, t2.t2_c2, t3.t3_c2 
  FROM t2  
  FULL JOIN t3  
  ON(t2.t2_c1 = t3.t3_c1);
`` `

### IF 语句

`` `SQL
  DECLARE @n1 int, @n2 int
  SET @n1 = 2
  SET @n2 = 20
  IF @n1 < @n2
  BEGIN
    PRINT '@n1小于@n2';
  END
  ELSE IF @n1=@n2
  BEGIN
    PRINT '@n1等于@n2';
  END
  ELSE
  BEGIN
    PRINT '@n1大于@n2'
  END
  GO
`` `

### CASE 语句

`` `SQL
  SELECT 学号 = s_no, 姓名及爱好 = 
    CASE s_no   
  WHEN '20060201' THEN '李好,游泳' 
  WHEN '20060202' THEN '王丫,登山' 
  ELSE '没有这个人'   
    END   
  FROM student 
`` `

### WHILE 语句

`` `SQL
  DECLARE @n int, @i int, @resulet int;  -- 计算 n 的阶乘 n! 
  SET @n = 5; 
  SET @i = 1;  
  SET @resulet = 1; 
  WHILE @i <= @n 
  BEGIN  
  SET @resulet = @resulet * @i; 
  SET @i = @i + 1; 
  END  
  PRINT @resulet
`` `

### 字符串数据和数值型数据的转换 

`` `SQL
  DECLARE @f float, @s varchar(20);   -- 数值型数据 → 字符串数据  
  SET @f=3.14159;  
  SET @s=CONVERT(varchar(20),@f);  
  --------------------------------------------------  
  DECLARE @f float, @s varchar(20);   -- 字符串数据 → 数值型数据  
  SET @s='1.73205';  
  SET @f=CONVERT(float,@s);
`` `

### 时间类型数据和字符串类型数据的转换 

`` `SQL
  DECLARE @dt datetime, @str varchar(30);   -- 时间数据 → 字符串数据  
  SET @dt=GETDATE(); 
  SET @str=CONVERT(varchar(30), @dt, 114);  
  SET @str=CONVERT(varchar(30), @dt, 111); 
  PRINT @str   
  --------------------------------------------------  
  DECLARE @dt datetime, @str varchar(30);   -- 字符串数据 → 时间数据  
  SET @str = '2009/09/12';  
  SET @dt=CONVERT(datetime, @str); 
  PRINT @dt;
`` `

### 获取服务器、数据库、应用程序、用户、登录等名称 

`` `SQL
  PRINT HOST_NAME();    -- 获取服务器名 
  PRINT DB_NAME();    -- 获取数据库名 
  PRINT APP_NAME();   -- 获取应用程序名 
  PRINT USER_NAME();    -- 获取数据库用户名 
  PRINT SUSER_SNAME();    -- 获取登录名
`` `

## 系统视图,系统表,系统存储过程的使用

### 获取数据库中的用户表信息

#### 获取特定库中所有用户表信息

`` `SQL
  SELECT * FROM sys.tables
  SELECT * FROM sys.objects WHERE type='U'    -- 用户表
  -- 第二条语句中当type='S'时是系统表
`` `

#### 获取表的字段信息

`` `SQL
  SELECT * FROM sys.columns
  WHERE object_id=object_id('表名')
  SELECT * FROM syscolumns 
  WHERE id=OBJECT_ID('表名')
`` `

#### 获取当前库中表的字段及类型信息

`` `SQL
  SELECT '字段名'=a.name,
      '类型名'=b.name,
      '字段长度'=a.max_length,
      '参数顺序'=a.column_id
  FROM sys.columns a
  LEFT JOIN sys.types b ON a.user_type_id=b.user_type_id
  WHERE object_id=object_id('表名') 
  -- syscolumns与sys.columns表用法类似。
`` `

### 获取索引或主键信息

#### 获取对象及对应的索引的信息

`` `SQL
  SELECT '对象名'= A.name,
      '对象类型'= a.type,
      '索引名'= B.name,
      '索引类型'= CASE b.type
    WHEN 1 THEN '聚集索引'
    WHEN 2 THEN '非聚集索引'
    WHEN 3 THEN 'xml索引'
    ELSE '空间索引'
  END,
  '主键否' = CASE
    WHEN b.is_primary_key=1 THEN '主键'
    ELSE ''
  END
  FROM sys.objects A
  JOIN sys.indexes B ON A.object_id=B.object_id
  WHERE A.type='U'
    AND B.name IS NOT NULL
  ORDER BY a.name
`` `
#### 获取表的主键及对应的字段  

`` `SQL
  SELECT '表名'=d.name ,
          '主键名'=a.name,
          '字段名'=c.name
  FROM sys.indexes a
  JOIN sys.index_columns b ON a.object_id=b.object_id
  AND a.index_id=b.index_id
  JOIN sys.columns c ON a.object_id=c.object_id
  AND c.column_id=b.column_id
  JOIN sys.objects d ON d.object_id=c.object_id
  WHERE a.is_primary_key=1
------------------------------------------------------
  SELECT '表名'=OBJECT_NAME(b.parent_obj),
  '主键名'=c.name,
  '字段名'=a.name
  FROM syscolumns a,
      sysobjects b,
      sysindexes c,
      sysindexkeys d
  WHERE b.xtype = 'PK'
    AND b.parent_obj = a.id
    AND c.id = a.id
    AND b.name = c.name
    AND d.id = a.id
    AND d.indid = c.indid
    AND a.colid = d.colid
------------------------------------------------------
  SELECT '所属架构'=s.name ,         
    '表名'=t.name,        
    '主键名'=k.name ,        
      '列名'=c.name,         
    '键列序数'=ic.key_ordinal
  FROM sys.key_constraints AS k
  JOIN sys.tables AS t
    ON t.object_id = k.parent_object_id
  JOIN sys.schemas AS s     
    ON s.schema_id = t.schema_id
  JOIN sys.index_columns AS ic     
    ON ic.object_id = t.object_id
  AND ic.index_id = k.unique_index_id
  JOIN sys.columns AS c     
    ON c.object_id = t.object_id
  AND c.column_id = ic.column_id
  WHERE k.type = 'pk';
------------------------------------------------------
  -- 使用系统存储过程获取指定表的主键信息 
  EXEC sp_pkeys '表名' -- 表名只能是当前数据库下的单独表名不能带上架构名
`` `
#### 查询哪些表创建了主键

`` `SQL
  SELECT '表名'=a.name
  FROM
    (SELECT name,
            object_id
    FROM sys.objects
    WHERE TYPE='u') a
  LEFT JOIN sys.indexes b ON a.object_id=b.object_id
  AND b.is_primary_key=1
  WHERE b.name IS NOT NULL 
  -- 注:查询哪些表没有创建主键,将WHERE条件改成 IS NULL 即可。
`` `

### 查看视图信息

#### 查看视图属性信息

`` `SQL
  EXEC sp_help '视图名'
`` `

#### 查看创建视图脚本

`` `SQL
  EXEC sp_helptext '视图名'
`` `

#### 查看当前数据库所有视图基本信息

`` `SQL
  SELECT * FROM sys.views
  SELECT * FROM sys.objects
  WHERE TYPE='V'
    SELECT *
    FROM INFORMATION_SCHEMA.VIEWS
`` `

#### 查看视图对应的字段及字段属性

`` `SQL
  SELECT '视图名'=a.name,
    '列名'=b.name,
    '字段类型'=TYPE_NAME(b.system_type_id),
    '字段长度'=b.max_length
  FROM sys.views a
  JOIN sys.columns b ON a.object_id=b.object_id
  ORDER BY a.name 
`` `

#### 获取视图中的对象信息 

`` `SQL
  EXEC sp_depends '视图名'
`` `

### 查看存储过程信息

#### 基本信息

`` `SQL
  SELECT * FROM sys.procedures
  SELECT * FROM sys.objects
  WHERE TYPE='P'
`` `

#### 查看存储过程创建文本

`` `SQL
  sp_helptext 存储过程名称
  SELECT text
  FROM syscomments
  WHERE id=object_id (存储过程名称)
`` `

#### 查看存储过程的参数信息

`` `SQL
  SELECT '参数名称' = name,
          '类型' = type_name(xusertype),
          '长度' = LENGTH, '参数顺序' = colid
  FROM syscolumns
  WHERE id=object_id(存储过程名称)
  ---------------------------------------------------------------------------------------------------
  SELECT '参数名称' = name,
          '类型' = type_name(system_type_id),
          '长度' = max_length,
          '参数顺序' =parameter_id
  FROM sys.parameters
  WHERE object_id=object_id(存储过程名称)     -- 返回当前环境中可查询的指定表或视图的列信息。 
  EXEC sp_columns 表名
    SELECT * FROM sys.columns WHERE object_id=OBJECT_id(表名)
    SELECT * FROM sys.syscolumns WHERE id=OBJECT_ID(表名)
    SELECT * FROM information_schema.columns WHERE TABLE_NAME=表名        -- 查询存储过程或函数的参数的详细信息
    SELECT * FROM sys.parameters WHERE object_id=object_id(函数或存储过程名称)
`` `

### 获取触发器的相关信息

#### 查看触发器定义及相关属性信息

`` `SQL
  EXEC sp_help '触发器名'
  -- 查看表中指定类型的触发器的属性信息 
  EXEC sp_helptrigger ['表名'][,['触发器类型']] 
  --参数2可选,省略参数2时返回该表中所有类型的触发器属性
`` `

#### 获取触发器的创建脚本

`` `SQL
  EXEC sp_helptext '触发器名'
`` `

#### 查看表中禁用的触发器

`` `SQL
  SELECT name
  FROM sys.triggers
  WHERE parent_id=object_id('表名')
    AND is_disabled=1 
  -- 注:is_disabled=0时为启用的触发器。
`` `

#### 获取触发器的父类名,触发器名,触发器状态和触发器类型信息

`` `SQL
  SELECT '父类名'=a.name,
    '对象类型'=a.type,
    '触发器名'=b.name,
    '触发器状态'=CASE 
      WHEN b.is_disabled=1 
      THEN'禁用' 
      ELSE '启用' 
      END,
    '触发器类型'=CASE 
      WHEN b.is_instead_of_trigger=1 
      THEN 'instead of' 
      ELSE 'after' 
      END
  FROM sys.objects a
  JOIN sys.triggers b ON a.object_id=b.parent_id 
  -- 注:查询单个表或视图的触发器信息加上a.object_id=object_id(表名)条件
`` `

#### 禁用和启用触发器命令

`` `SQL
  -- 禁用:
  ALTER TABLE表名disable TRIGGER触发器名 
  -- 启用:
  ALTER TABLE表名enable TRIGGER触发器名 
  -- 注:禁用或启用多个触发器,触发器名之间用逗号隔开,禁用或启用表中全部触发器,将触发器名换成ALL。
`` `
#### 指定第一个或最后一个触发的AFTER触发器。 

`` `
  EXEC sp_settriggerorder '触发器名',   '执行顺序', '触发事件' 
  -- 查询触发触发器的对应事件
  SELECT * FROM sys.trigger_events
  WHERE object_id=object_id('触发器名') 
`` `

#### 重命名触发器 

`` `SQL
  EXEC sp_rename 旧名,新名
`` `

### 查看数据库关于权限的信息

`` `SQL
  --查询当前数据库角色信息
  EXEC sp_helprole 角色名 
  --提供有关每个数据库中的登录及相关用户的信息
  EXEC sp_helplogins 登录名 
  --报告有关当前数据库中数据库级主体的信息。
  EXEC sp_helpuser 当前数据库用户或角色名 
  --返回有关当前数据库中某个角色的成员的信息
  EXEC sp_helprolemember 角色名 
  --返回SQL Server 固定服务器角色的列表
  EXEC sp_helpsrvrole 固定服务器角色名
`` `

@NoahDragon
Copy link
Member

看不出有什么问题……会不会有cache的CSS style文件在server?

@Meli55a
Copy link
Author

Meli55a commented Oct 28, 2016

那有没有办法清理呢?能否可以把本地的 hexo 再重装安装一遍?

@backeyshy
Copy link

内嵌代码用
'''
文本
'''
会不会是这个问题

@Meli55a
Copy link
Author

Meli55a commented Oct 28, 2016

应该还是哪里的缓存的问题,这些文章之前显示是没有问题的

@NoahDragon
Copy link
Member

@backeyshy 那个 ``` 是我改的为了显示方便

@NoahDragon
Copy link
Member

@Meli55a 可否试一下deploy到一个新的folder,看看问题是否能解决?

@Meli55a
Copy link
Author

Meli55a commented Oct 29, 2016

重新安装了hexo,最终问题解决,感谢@NoahDragon 的回复,使我没有放弃hexo而投入wordpress!摸摸大!

@NoahDragon
Copy link
Member

👍 解决了就好~

@allennic
Copy link

allennic commented Nov 3, 2016

我hexo g后,生成的所有html文件导入js标签后面有?v=x.x.x。导致页面文件404,页面空白,大牛请问咋回事??
image

@allennic
Copy link

allennic commented Nov 3, 2016

hexo s显示正常

@NoahDragon
Copy link
Member

@allennic ?=应该对js文件路径没有影响,只是一种强制浏览器更新缓存的方法。对于页面404,请到public目录下看相应的文件是否生成?

另:请单开Issue,防止跑偏。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants