CREATE TABLE department3(
id INT AUto_INCREMENT PRIMARY KEY COMMENT ’自增,主键
dept_name VARCHAR(20) NOT NULL UNIQUE COMMENT ‘唯一键
dept_phone CHAR(13) COMMENT ‘部门电话’,
dept_memo VARCHAR(100)COMMENT ‘ 备注
)
SHOW TABLES
-#-------创建员工表-------
CREATE TABLE staffer(
id INT AUTO INCREMENT PRIMARY KEY,
staff_name VARCHAR(15) NOT NULL,
dept id INT
sex ENUM(‘F’,‘M’) DEFAULT ‘F
phone CHAR(11),
salary DOUBLE(9,1) CHECK(salary >0 AND salary <= 100000),
staff_ memo VARCHAR(200) ,
FOREIGN KEY(dept_ id) REFERENCES departmeny(id)
)
#----顾客表----
CREATE table customer1(
costomer_ id INT AUTO_ _INCREMENT PRIMARY KEY COMMENT ‘主键’,
customer_ name VARCHAR(10) NOT NULL COMMENT ‘顾客名字’,
sex enum(‘n’,‘v’) DEFAULT ‘N’ COMMENT ‘性别n男v女’,
dirthday datetime COMMENT ‘出生 日期’,
hobby SET( ‘music’, ‘ball’) COMMENT ‘ 爱好’
consumption_ _amount DOUBLE(5,1) UNSIGNED DEFAULT 0 COMMENT ‘消费金额
mender_ _balance DECIMAL(5,2) UNSIGNED DEFAULT 0 COMMENT ‘会员余额’,
photo VARCHAR(250),
address json
)
--------复制表结构--------------
CREATE TABLE IF NOT EXISTS staffer_ _bak
LIKE Jstaffer
DESC staffer. _bak
DESC staffer_ bak|
mysql写emp员工数据表,可以参考 百度文库实例链接如下:
http://wenku.baidu.com/link?url=qQyWIdyO14dKcBVBF1EO8hNVwz520Mff6K646mKxVh25751A6IE4-3yyusI-czXQrBecItv_PYEIjef_ryo6g0MFuQUGm72Ah6Ngcqie_VS
oracle循环分while循环,for循环等等,怎么可能像你这样,直接就来个loop
另外,执行insert *** 作在oracle里需要commit
创建测试表:
create table z_dep_06(dep_id number(20),
dep_name varchar2(20))
执行:
declarenum1 number := 1
begin
while num1 <= 1000 loop
insert into z_dep_06 (dep_id, dep_name) values (num1, '售后部')
commit
num1 := num1 + 1
end loop
end
剩下的那个你自己照着上边改改吧,顺便也自己理解一下。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)