每年创建一个新的数据库表 [英] Create a new database table every year

查看:109
本文介绍了每年创建一个新的数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须基于使用大数据库的现有Excel应用程序创建一个新应用程序.对于新应用程序,我将使用Microsoft Web Developer(VB.NET).Excel应用程序处理一些订单以及与这些订单相关的一些数据.

I must create a new application based on an existing Excel application that uses a big database. For the new application I will use Microsoft Web Developer (VB.NET). The Excel application handles some orders and some data related to those orders.

因为它是一个很大的数据库,所以我需要以编程方式每年创建一个表.例如:2013年的订单将在Orders_2013中,2014年的订单将在Orders_2014中,以此类推.如果我搜索从2012年到现在是2013年的订单,则该应用程序应该能够在特定的数据库表中进行搜索.

Because it is a big database, I need to create programmatically a table for every year. For example: orders from 2013 will be in Orders_2013, orders from 2014 will be in Orders_2014 and so on ... But my new application should be able to search in all the tables; if I search for an order that from 2012 and now is 2013 the application should be able to search in the specific database table.

我必须使用旧的数据库结构,这是一种挫折.如果创建新的数据库结构,我必须能够从旧数据库中导入所有内容.

I must use the old database structure, and that is kind of a setback. If I create a new database structure I must be able to import everything from the old database.

每年我需要一些有关如何构建应用程序以创建新数据库的指导.

I need some guidance on how to build the application to create a new database, for every year.

我阅读了一些有关SQL Management Studio的内容,我可以使用一个任务来创建脚本,以便每年生成一个新表,但是到目前为止,我还无法创建一个表.我会继续搜索,但是如果有人知道我在寻找什么,请分享该信息.

I read something about SQL Management Studio, that I can use a task to create a script, for generating a new table every year, but I have not been able to create one so far. I will keep searching, but if someone knows what I'm looking for, please share that info.

推荐答案

让我开始说,我将主张一个单一的表设计,同时采用视图来保持向后兼容性.我将假设您束手无策,根本无法修改表结构,因此无法使用单表.

Let me start by saying that I would advocate a single table design, while employing views to maintain backward compatibility. I am going to assume that you have your hands tied and cannot modify your table structure at all and hence unable to use a singe table.

在SQL Management Studio中,可以在设计视图"中创建年表之一.完成后,您可以右键单击表并使其生成CREATE TABLE脚本,您可以每年使用不同的表名执行该脚本.我不知道SQL Management Studio是否可以安排它,但我自己会做一次,因为它每年只有一次.

In SQL Management Studio, you can create one of the yearly table in "Design View". Once done, you can right-click on the table and have it generate a CREATE TABLE script, which you can execute every year, with a different table name. I don't know if the SQL Management Studio can schedule it, but I would simple do it myself since its only once per year.

对于统一搜索,您可以创建一个视图,该视图是所有特定年份表的联合,然后在该表上进行搜索.这样,您只需修改搜索组件即可使用新视图.但是,您还必须每年都更新此视图,这应该非常简单.

As for the unified search, you can create a view which is a union of all the year specific tables and search over that. This way you will only have to modify only the search component to work with the new view. However, you will also have to update this view every year as well, which should be pretty simple.

这篇关于每年创建一个新的数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆