My Programming Notes

Here are Notes.... come from debugging

My Programming Notes

Here are Notes.... come from debugging

شنبه, ۱۰ تیر ۱۳۹۶، ۱۲:۲۷ ب.ظ

اطلاعات ستون های جداول پایگاه داده

برای مستند سازی از قسمتی از پروژه ای که روش کار می کنم نیاز داشتم تمام اطلاعات ستون های جداول رو بهتر بشناسم . برای این کار از INFORMATION_SCHEMA.COLUMNS  استفاده کردم :


INFORMATION_SCHEMA.COLUMNS یک VIEW است که قابلیت نمایش اطلاعات تمام ستون های تمام جداول و View های موجود در جداول را داراست.




Column name

Data type

Description

TABLE_CATALOG

nvarchar(128)

Table qualifier.

TABLE_SCHEMA

nvarchar(128)

Name of schema that contains the table.

TABLE_NAME

nvarchar(128)

Table name.

COLUMN_NAME

nvarchar(128)

Column name.

ORDINAL_POSITION

int

Column identification number.

Note: In SQL Server 2005, these column IDs are consecutive numbers.

COLUMN_DEFAULT

nvarchar(4000)

Default value of the column.

IS_NULLABLE

varchar(3)

Nullability of the column. If this column allows for NULL, this column returns YES. Otherwise, NO is returned.

DATA_TYPE

nvarchar(128)

System-supplied data type.

CHARACTER_MAXIMUM_LENGTH

int

Maximum length, in characters, for binary data, character data, or text and image data.

-1 for xml and large-value type data. Otherwise, NULL is returned. For more information, see Data Types (Transact-SQL).

CHARACTER_OCTET_LENGTH

int

Maximum length, in bytes, for binary data, character data, or text and image data.

-1 for xml and large-value type data. Otherwise, NULL is returned.

NUMERIC_PRECISION

tinyint

Precision of approximate numeric data, exact numeric data, integer data, or monetary data. Otherwise, NULL is returned.

NUMERIC_PRECISION_RADIX

smallint

Precision radix of approximate numeric data, exact numeric data, integer data, or monetary data. Otherwise, NULL is returned.

NUMERIC_SCALE

int

Scale of approximate numeric data, exact numeric data, integer data, or monetary data. Otherwise, NULL is returned.

DATETIME_PRECISION

smallint

Subtype code for datetime and SQL-92 interval data types. For other data types, NULL is returned.

CHARACTER_SET_CATALOG

nvarchar(128)

Returns master. This indicates the database in which the character set is located, if the column is character data or text data type. Otherwise, NULL is returned.

CHARACTER_SET_SCHEMA

nvarchar(128)

Always returns NULL.




در تصاویر زیر حاصل اجرای کوئری مربوطه در پایگاه داده AdventureWorks را مشاهده می کنید:


 SELECT * FROM INFORMATION_SCHEMA.COLUMNS



183_in1




183_in2




183_in3



183_in4





183_in5


اگر می خواهید فقط اطلاعات یک جدول را ببینید :
  
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Address'

موفق باشید.


تلگرام : https://t.me/GCC_co

اینستاگرام:  https://www.instagram.com/golden.cube.computing



نظرات  (۰)

هیچ نظری هنوز ثبت نشده است

ارسال نظر

ارسال نظر آزاد است، اما اگر قبلا در بیان ثبت نام کرده اید می توانید ابتدا وارد شوید.
شما میتوانید از این تگهای html استفاده کنید:
<b> یا <strong>، <em> یا <i>، <u>، <strike> یا <s>، <sup>، <sub>، <blockquote>، <code>، <pre>، <hr>، <br>، <p>، <a href="" title="">، <span style="">، <div align="">
تجدید کد امنیتی