oracle存储过程动态建表
PROCEDUREup_CreateTable(tableName_inINVARCHAR2)ASSQL_inVARCHAR2(5000);BEGINSQL_in:='C...
PROCEDURE up_CreateTable
(
tableName_in IN VARCHAR2
)
AS
SQL_in VARCHAR2(5000);
BEGIN
SQL_in := 'CREATE TABLE "'||tableName_in||'"
(
DM VARCHAR2(20) NOT NULL,
MC VARCHAR2(60) NOT NULL,
BZSM VARCHAR2(100)
)tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 1M
minextents 1
maxextents unlimited
);
alter table "'||tableName_in||'"
add constraint PK_'||tableName_in||' Primary key(DM)';
EXECUTE IMMEDIATE SQL_in ;
END; 展开
(
tableName_in IN VARCHAR2
)
AS
SQL_in VARCHAR2(5000);
BEGIN
SQL_in := 'CREATE TABLE "'||tableName_in||'"
(
DM VARCHAR2(20) NOT NULL,
MC VARCHAR2(60) NOT NULL,
BZSM VARCHAR2(100)
)tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 1M
minextents 1
maxextents unlimited
);
alter table "'||tableName_in||'"
add constraint PK_'||tableName_in||' Primary key(DM)';
EXECUTE IMMEDIATE SQL_in ;
END; 展开
展开全部
PROCEDURE up_CreateTable
(
tableName_in IN VARCHAR2
)
AS
Declare SQL_in VARCHAR2(5000);
BEGIN
SQL_in := 'CREATE TABLE '||tableName_in||'
(
DM VARCHAR2(20) NOT NULL,
MC VARCHAR2(60) NOT NULL,
BZSM VARCHAR2(100)
)tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 1M
minextents 1
maxextents unlimited
)';
EXECUTE IMMEDIATE SQL_in ;
SQL_in :='alter table '||tableName_in||' add constraint PK_'||tableName_in||' Primary key(DM)';
EXECUTE IMMEDIATE SQL_in ;
END;
(
tableName_in IN VARCHAR2
)
AS
Declare SQL_in VARCHAR2(5000);
BEGIN
SQL_in := 'CREATE TABLE '||tableName_in||'
(
DM VARCHAR2(20) NOT NULL,
MC VARCHAR2(60) NOT NULL,
BZSM VARCHAR2(100)
)tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 1M
minextents 1
maxextents unlimited
)';
EXECUTE IMMEDIATE SQL_in ;
SQL_in :='alter table '||tableName_in||' add constraint PK_'||tableName_in||' Primary key(DM)';
EXECUTE IMMEDIATE SQL_in ;
END;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询