Sysdatabaes table and sysobjects table

Time:2021-1-27

Sysdatabases table

Sysdatabases is a table in the master databaseread-onlyTable, which contains all the database information

 

When creating a database, check its existence

use master
 go
 If exists (select * from sysdatabases where name ='Database name ')
 Drop database name
 Create database name
 go

 

Sysobjects table

Sysobjects is a table in all databases, which records the information of no object created in the database

 

Create a new table in the database: check whether the table already exists

use student
go
If exists (select * from sysobjects where condition (contains name and type, table type is' U '))
drop table s
Create tables (fields)
go