zoukankan      html  css  js  c++  java
  • sql server 查询表名,存储过程,列名等

    --1:获取当前数据库中的所有用户表

    select Name from sysobjects where xtype='u' and status>=0

    --2:获取某一个表的所有字段

    select name from syscolumns where id=object_id(N'表名')

    --3:查看与某一个表相关的视图、存储过程、函数

    select a.* from sysobjects a, syscomments b where a.id = b.id and b.text like '%表名%'

    --4:查看当前数据库中所有存储过程

    select name as 存储过程名称 from sysobjects where xtype='P'

    --5:查询用户创建的所有数据库

    select * from master..sysdatabases D where sid not in(select sid from master..syslogins where name='sa')

    或者

    select dbid, name AS DB_NAME from master..sysdatabases where sid <> 0x01

    --6:查询某一个表的字段和数据类型

    select column_name,data_type from information_schema.columns
    where table_name = N'表名'

    --7:获取数据库文件路径

    select ltrim(rtrim(filename)) from 数据库名..sysfiles where charindex('MDF',filename)>0
    or
    select ltrim(rtrim(filename)) from 数据库名..sysfiles where charindex('LDF',filename)>0

  • 相关阅读:
    python3
    python2
    python的爬虫
    SQL SEVERE 基本用法 1
    安装SQL SEVER 2017 express 轻量入门级软件 安装教程
    面试学习资料
    后端架构师--总结网址收藏(个人)
    JVM学习网址(收集总结)
    RabbitMQ--学习资源汇
    Redis 学习资料目录(Important)
  • 原文地址:https://www.cnblogs.com/bdf216/p/2649071.html
Copyright © 2011-2022 走看看