当前位置:网站首页>SQL statement to view the basic table structure and constraint fields, primary codes and foreign codes in the table (simple and effective)

SQL statement to view the basic table structure and constraint fields, primary codes and foreign codes in the table (simple and effective)

2022-06-10 19:13:00 _ xwh

①exec sp_helpconstraint ‘ Table name ’: You can query various constraint attributes in the table ( Field ), Including the ability to view which field in the table is foreign code 、 Main code 、 The scope of the property

②sp_help + Table name or sp_columns + Table name : View elements and basic structure in the table

③ To query the data inserted in the basic table, you can use :
select * from table
and select * from table t where t.id=(select last_insert_id()) You can rely on the key code to query a single specific data , Here t.id It's a watch t The main code in ( Because the query is completed by the main code ),t.id Followed by the corresponding main code value in the inserted data .

原网站

版权声明
本文为[_ xwh]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101814526603.html