zoukankan      html  css  js  c++  java
  • Oracle 和 Mysql 查询表字段信息

    查看格式:
    oracle:

    SELECT
    	tc.column_name AS "columnName",
    	cc.comments AS "comments",
    	tc.data_type AS "dataType",
    	tc.data_length AS "dataLength",
    	tc.nullable AS "nullable",
    	(
    		SELECT
    			COUNT (*)
    		FROM
    			user_cons_columns U,
    			user_constraints c
    		WHERE
    			U .constraint_name = c.constraint_name
    		AND c.constraint_type = 'P'
    		AND U .table_name = tc.table_name
    		AND U .column_name = tc.column_name
    	) AS "primaryKey"
    FROM
    	user_tab_columns tc,
    	user_col_comments cc
    WHERE
    	tc.table_name = cc.table_name
    AND tc.column_name = cc.column_name
    AND tc.table_name = 'SYS_TASK';
    

    mysql:

    SELECT
    	COLUMN_NAME AS "columnName",
    	COLUMN_COMMENT AS "comments",
    	DATA_TYPE AS "dataType",
    	CHARACTER_MAXIMUM_LENGTH AS "dataLength",
    	(case when IS_NULLABLE='NO' then 'N' else 'Y' end) AS "nullable",
    	(case when COLUMN_KEY='PRI' then '1' else '0' end) AS "primaryKey"
    FROM
    	information_schema.`COLUMNS`
    WHERE
    	TABLE_SCHEMA = 'mgl'
    AND TABLE_NAME = 'SYS_TASK';
    
  • 相关阅读:
    计算机网络基础 汇总
    指针与数组
    卡特兰数
    Leetcode Sort Colors
    Leetcode Group Shifted Strings
    Leetcode Summary Ranges
    Leetcode Count Primes
    Leetcode Reverse Words in a String II
    Leetcode Reverse Words in a String
    Leetcode Rotate Array
  • 原文地址:https://www.cnblogs.com/chonghaojie/p/10384406.html
Copyright © 2011-2022 走看看