sql >> データベース >  >> RDS >> Sqlserver

テーブルのスキーマ名を取得する方法

    OBJECT_SCHEMA_NAME を使用します

    SELECT 
      OBJECT_SCHEMA_NAME(f.parent_object_id) AS TableNameSchema, -- this
      OBJECT_NAME(f.parent_object_id) AS TableName,
      COL_NAME(fc.parent_object_id,fc.parent_column_id) AS ColumnName,
      OBJECT_SCHEMA_NAME(f.referenced_object_id) AS ReferenceTableNameSchema,
      OBJECT_NAME (f.referenced_object_id) AS ReferenceTableName,
      COL_NAME(fc.referenced_object_id,fc.referenced_column_id) AS ReferenceColumnName,
      f.name AS ForeignKey
    FROM
      sys.foreign_keys AS f
      INNER JOIN sys.foreign_key_columns AS fc ON f.OBJECT_ID = fc.constraint_object_id
      INNER JOIN sys.objects AS o ON o.OBJECT_ID = fc.referenced_object_id
      

    1. postgresで不明な行の値を列名に動的に転置する

    2. 7645ヌルまたは空のフルテキスト述語

    3. データベースユーザー権限とは何ですか?

    4. Spring、DBCP、MySQLとの接続タイムゾーンの設定