s1(java)项目实战(固定资产管理)(SQL_sever)

该博客介绍了如何在SQL Server中创建名为'asset'的数据库,详细展示了数据库的创建和配置过程,以及相关表的删除与重建。包括Action, Asset, ChildKind, Employee, FatherKind和Manager六张表的设计,每张表的字段及约束条件,如主键和外键关系。" 112788381,10526154,信贷与经济危机:生产过剩的根源,"['经济学', '金融', '经济模型', '宏观经济', '债务管理']
摘要由CSDN通过智能技术生成

 IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'asset')
 DROP DATABASE [asset]
GO

CREATE DATABASE [asset]  ON (NAME = N'asset_Data', FILENAME = N'D:/41y01/project/asset_Data.MDF' , SIZE = 2, FILEGROWTH = 10%) LOG ON (NAME = N'asset_Log', FILENAME = N'D:/41y01/project/asset_Log.LDF' , SIZE = 1, FILEGROWTH = 10%)
 COLLATE Chinese_PRC_CI_AS
GO

exec sp_dboption N'asset', N'autoclose', N'false'
GO

exec sp_dboption N'asset', N'bulkcopy', N'false'
GO

exec sp_dboption N'asset', N'trunc. log', N'true'
GO

exec sp_dboption N'asset', N'torn page detection', N'false'
GO

exec sp_dboption N'asset', N'read only', N'false'
GO

exec sp_dboption N'asset', N'dbo use', N'false'
GO

exec sp_dboption N'asset', N'single', N'false'
GO

exec sp_dboption N'asset', N'autoshrink', N'true'
GO

exec sp_dboption N'asset', N'ANSI null default', N'false'
GO

exec sp_dboption N'asset', N'recursive triggers', N'false'
GO

exec sp_dboption N'asset', N'ANSI nulls', N'false'
GO

exec sp_dboption N'asset', N'concat null yields null', N'false'
GO

exec sp_dboption N'asset', N'cursor close on commit', N'false'
GO

exec sp_dboption N'asset', N'default to local cursor', N'false'
GO

exec sp_dboption N'asset', N'quoted identifier', N'false'
GO

exec sp_dboption N'asset', N'ANSI warnings', N'false'
GO

exec sp_dboption N'asset', N'auto create statistics', N'true'
GO

exec sp_dboption N'asset', N'auto update statistics', N'true'
GO

use [asset]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_ChildKind_FatherKind]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[ChildKind] DROP CONSTRAINT FK_ChildKind_FatherKind
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Action]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Action]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Asset]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Asset]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ChildKind]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[ChildKind]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Employee]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Employee]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FatherKind]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[FatherKind]
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Manager]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Manager]
GO

CREATE TABLE [dbo].[Action] (
 [asset_id] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [action_time] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [manager_id] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [asset_use] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
 [remark] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Asset] (
 [asset_id] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [asset_name] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [asset_type] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [asset_price] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [asset_buytime] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [asset_status] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [asset_user] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
 [remark] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
 [childkind_id] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[ChildKind] (
 [fatherkind_id] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [childkind_id] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [childkind_name] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Employee] (
 [employee_id] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [employee_name] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [employee_post] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [remark] [varchar] (50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[FatherKind] (
 [fatherkind_id] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [fatherkind_name] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[Manager] (
 [manager_id] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [manager_username] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
 [manager_password] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Asset] WITH NOCHECK ADD
 CONSTRAINT [PK_Asset] PRIMARY KEY  CLUSTERED
 (
  [asset_id]
 )  ON [PRIMARY]
GO

ALTER TABLE [dbo].[ChildKind] WITH NOCHECK ADD
 CONSTRAINT [PK_ChildKind] PRIMARY KEY  CLUSTERED
 (
  [childkind_id]
 )  ON [PRIMARY]
GO

ALTER TABLE [dbo].[FatherKind] WITH NOCHECK ADD
 CONSTRAINT [PK_MainKind] PRIMARY KEY  CLUSTERED
 (
  [fatherkind_id]
 )  ON [PRIMARY]
GO

ALTER TABLE [dbo].[Manager] WITH NOCHECK ADD
 CONSTRAINT [PK_Manager] PRIMARY KEY  CLUSTERED
 (
  [manager_id]
 )  ON [PRIMARY]
GO

ALTER TABLE [dbo].[ChildKind] ADD
 CONSTRAINT [FK_ChildKind_FatherKind] FOREIGN KEY
 (
  [fatherkind_id]
 ) REFERENCES [dbo].[FatherKind] (
  [fatherkind_id]
 )
GO

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值