SQL – Display Primary and Foreign Key Relationships Table With Their Constraints

In below query, We can view the relationships between more than one table as primary and foreign key … SELECT PK_Table = PK.TABLE_NAME,PK_Column = PT.COLUMN_NAME,K_Table = FK.TABLE_NAME,FK_Column = CU.COLUMN_NAME,Constraint_Name = C.CONSTRAINT_NAMEFROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS CINNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS FK ON C.CONSTRAINT_NAME = FK.CONSTRAINT_NAMEINNER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS PK ON C.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAMEINNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE CU ON C.CONSTRAINT_NAME = CU.CONSTRAINT_NAMEINNER JOINContinue reading “SQL – Display Primary and Foreign Key Relationships Table With Their Constraints”

Top 10 SQL Interview Questions

What is SQL ?SQL is Structured Query Language . This is a standard language used to perform tasks such as INSERT/UPDATE/DELETE and SELECT of data from a database. What is Database ?Database is nothing but an organized form of data for easy access, storing, retrieval and managing of data. Constraints in SQL ?NOT NULL –Continue reading “Top 10 SQL Interview Questions”

Create your website at WordPress.com
Get started