7 个解决方案
#1
用Command来执行一个类似于"create table..........."
之类的sql就可以了
之类的sql就可以了
#2
比如
SqlCommand com = new SqlCommand("create table mycreatetable(id int identity,name varchar(20))",yourSqlConnection);
yourSqlConnection.Open();
com.ExecuteNonQuery();
yourSqlConnection.Close();
SqlCommand com = new SqlCommand("create table mycreatetable(id int identity,name varchar(20))",yourSqlConnection);
yourSqlConnection.Open();
com.ExecuteNonQuery();
yourSqlConnection.Close();
#3
或者周密一些,用类似于下面的脚本
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[mycreatetable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[mycreatetable]
GO
CREATE TABLE [dbo].[mycreatetable] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[name] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
然后来执行这个脚本
http://blog.csdn.net/brightheroes/archive/2004/11/10/175929.aspx
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[mycreatetable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[mycreatetable]
GO
CREATE TABLE [dbo].[mycreatetable] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[name] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
然后来执行这个脚本
http://blog.csdn.net/brightheroes/archive/2004/11/10/175929.aspx
#4
执行如下Sql语句:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Roles]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Roles]
GO
CREATE TABLE [dbo].[Roles] (
[RoleID] [nvarchar] (32) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[RoleName] [nvarchar] (64) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Description] [nvarchar] (1024) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Roles]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Roles]
GO
CREATE TABLE [dbo].[Roles] (
[RoleID] [nvarchar] (32) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[RoleName] [nvarchar] (64) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Description] [nvarchar] (1024) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO
#5
/******************************************************************************
** File:
** Name: tabOrder_Core
** Desc: 订单主表
**
** Auth:
** Date: 2004-12-2 Modify:2004.12.15
*******************************************************************************/
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'U' AND name = 'tabOrder_Core')
BEGIN
DROP Table tabOrder_Core
END
GO
PRINT 'Creating Table tabOrder_Core'
GO
CREATE TABLE tabOrder_Core
(
Order_ID int primary key identity(1,1), /* 订单序号 */
Order_NO varchar(32) not null, /* 订单的编号 */
Pay_Order smallint not null , /* 支付次序 */
Pay_Mode smallint not null , /* 支付方式 */
Pay_Back smallint not null , --是否允许退货
ManTransType smallint not null , /* 人工配送方式 */
Trans_Charge money not null, --配送费用
OrderOwner_ID int not null, /* 订单所有者序号 */
Order_Time datetime not null, /* 订单产生的时间 */
SA_ID int not null, /**/
Status int not null default 0 /* 订单状态(0-未支付未发货,1-已支付未发货,2-未支付退货(配送单),3-已支付已发货,4-库存不足,保留值) */
)
GO
create index idx_OrdCore_NO on tabOrder_Core(Order_NO)
GO
** File:
** Name: tabOrder_Core
** Desc: 订单主表
**
** Auth:
** Date: 2004-12-2 Modify:2004.12.15
*******************************************************************************/
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'U' AND name = 'tabOrder_Core')
BEGIN
DROP Table tabOrder_Core
END
GO
PRINT 'Creating Table tabOrder_Core'
GO
CREATE TABLE tabOrder_Core
(
Order_ID int primary key identity(1,1), /* 订单序号 */
Order_NO varchar(32) not null, /* 订单的编号 */
Pay_Order smallint not null , /* 支付次序 */
Pay_Mode smallint not null , /* 支付方式 */
Pay_Back smallint not null , --是否允许退货
ManTransType smallint not null , /* 人工配送方式 */
Trans_Charge money not null, --配送费用
OrderOwner_ID int not null, /* 订单所有者序号 */
Order_Time datetime not null, /* 订单产生的时间 */
SA_ID int not null, /**/
Status int not null default 0 /* 订单状态(0-未支付未发货,1-已支付未发货,2-未支付退货(配送单),3-已支付已发货,4-库存不足,保留值) */
)
GO
create index idx_OrdCore_NO on tabOrder_Core(Order_NO)
GO
#6
楼上说了,就是用SQL语句啊,
CREATE TABLE publishers 主键是PRIMARY KEY
(
pub_id char(4) NOT NULL
CONSTRAINT UPKCL_pubind PRIMARY KEY CLUSTERED
pub_name varchar(40) NULL,
city varchar(20) NULL,
state char(2) NULL,
country varchar(30) NULL
DEFAULT('csdn')//默认
)
至于什么外键拉,你找找sql的帮助,很详细的
CREATE TABLE publishers 主键是PRIMARY KEY
(
pub_id char(4) NOT NULL
CONSTRAINT UPKCL_pubind PRIMARY KEY CLUSTERED
pub_name varchar(40) NULL,
city varchar(20) NULL,
state char(2) NULL,
country varchar(30) NULL
DEFAULT('csdn')//默认
)
至于什么外键拉,你找找sql的帮助,很详细的
#7
汗~~~谢谢各位,但是我看不懂,能在详细点吗?或者哪有教程之类的
#1
用Command来执行一个类似于"create table..........."
之类的sql就可以了
之类的sql就可以了
#2
比如
SqlCommand com = new SqlCommand("create table mycreatetable(id int identity,name varchar(20))",yourSqlConnection);
yourSqlConnection.Open();
com.ExecuteNonQuery();
yourSqlConnection.Close();
SqlCommand com = new SqlCommand("create table mycreatetable(id int identity,name varchar(20))",yourSqlConnection);
yourSqlConnection.Open();
com.ExecuteNonQuery();
yourSqlConnection.Close();
#3
或者周密一些,用类似于下面的脚本
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[mycreatetable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[mycreatetable]
GO
CREATE TABLE [dbo].[mycreatetable] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[name] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
然后来执行这个脚本
http://blog.csdn.net/brightheroes/archive/2004/11/10/175929.aspx
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[mycreatetable]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[mycreatetable]
GO
CREATE TABLE [dbo].[mycreatetable] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[name] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
GO
然后来执行这个脚本
http://blog.csdn.net/brightheroes/archive/2004/11/10/175929.aspx
#4
执行如下Sql语句:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Roles]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Roles]
GO
CREATE TABLE [dbo].[Roles] (
[RoleID] [nvarchar] (32) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[RoleName] [nvarchar] (64) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Description] [nvarchar] (1024) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Roles]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Roles]
GO
CREATE TABLE [dbo].[Roles] (
[RoleID] [nvarchar] (32) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[RoleName] [nvarchar] (64) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[Description] [nvarchar] (1024) COLLATE Chinese_PRC_CI_AS NOT NULL
) ON [PRIMARY]
GO
#5
/******************************************************************************
** File:
** Name: tabOrder_Core
** Desc: 订单主表
**
** Auth:
** Date: 2004-12-2 Modify:2004.12.15
*******************************************************************************/
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'U' AND name = 'tabOrder_Core')
BEGIN
DROP Table tabOrder_Core
END
GO
PRINT 'Creating Table tabOrder_Core'
GO
CREATE TABLE tabOrder_Core
(
Order_ID int primary key identity(1,1), /* 订单序号 */
Order_NO varchar(32) not null, /* 订单的编号 */
Pay_Order smallint not null , /* 支付次序 */
Pay_Mode smallint not null , /* 支付方式 */
Pay_Back smallint not null , --是否允许退货
ManTransType smallint not null , /* 人工配送方式 */
Trans_Charge money not null, --配送费用
OrderOwner_ID int not null, /* 订单所有者序号 */
Order_Time datetime not null, /* 订单产生的时间 */
SA_ID int not null, /**/
Status int not null default 0 /* 订单状态(0-未支付未发货,1-已支付未发货,2-未支付退货(配送单),3-已支付已发货,4-库存不足,保留值) */
)
GO
create index idx_OrdCore_NO on tabOrder_Core(Order_NO)
GO
** File:
** Name: tabOrder_Core
** Desc: 订单主表
**
** Auth:
** Date: 2004-12-2 Modify:2004.12.15
*******************************************************************************/
IF EXISTS (SELECT * FROM sysobjects WHERE type = 'U' AND name = 'tabOrder_Core')
BEGIN
DROP Table tabOrder_Core
END
GO
PRINT 'Creating Table tabOrder_Core'
GO
CREATE TABLE tabOrder_Core
(
Order_ID int primary key identity(1,1), /* 订单序号 */
Order_NO varchar(32) not null, /* 订单的编号 */
Pay_Order smallint not null , /* 支付次序 */
Pay_Mode smallint not null , /* 支付方式 */
Pay_Back smallint not null , --是否允许退货
ManTransType smallint not null , /* 人工配送方式 */
Trans_Charge money not null, --配送费用
OrderOwner_ID int not null, /* 订单所有者序号 */
Order_Time datetime not null, /* 订单产生的时间 */
SA_ID int not null, /**/
Status int not null default 0 /* 订单状态(0-未支付未发货,1-已支付未发货,2-未支付退货(配送单),3-已支付已发货,4-库存不足,保留值) */
)
GO
create index idx_OrdCore_NO on tabOrder_Core(Order_NO)
GO
#6
楼上说了,就是用SQL语句啊,
CREATE TABLE publishers 主键是PRIMARY KEY
(
pub_id char(4) NOT NULL
CONSTRAINT UPKCL_pubind PRIMARY KEY CLUSTERED
pub_name varchar(40) NULL,
city varchar(20) NULL,
state char(2) NULL,
country varchar(30) NULL
DEFAULT('csdn')//默认
)
至于什么外键拉,你找找sql的帮助,很详细的
CREATE TABLE publishers 主键是PRIMARY KEY
(
pub_id char(4) NOT NULL
CONSTRAINT UPKCL_pubind PRIMARY KEY CLUSTERED
pub_name varchar(40) NULL,
city varchar(20) NULL,
state char(2) NULL,
country varchar(30) NULL
DEFAULT('csdn')//默认
)
至于什么外键拉,你找找sql的帮助,很详细的
#7
汗~~~谢谢各位,但是我看不懂,能在详细点吗?或者哪有教程之类的