This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12794|Reply: 1

[Source] Oracle creates a new data table and inserts data

[Copy link]
Posted on 3/6/2015 3:45:55 PM | | | |


  1. --新建表空间
  2. create tablespace itsvse
  3. datafile 'd:\itsvse.dbf'
  4. size 10m;
  5. --新建用户
  6. create user itsvse
  7. identified by 123;
  8. --授权用户itsvse连接
  9. grant connect to itsvse;
  10. --授权用户使用资源
  11. grant resource to itsvse;




  12. --新建学生信息表
  13. create table stuInfo
  14. (
  15.        stuid number primary key,
  16.        stuname varchar(10) not null,
  17.        stusex varchar(2) check (stusex='男' or stusex='女'),
  18.        stubir date
  19. );

  20. --新建课程信息表
  21. create table subInfo
  22. (
  23.        subid number primary key,
  24.        subname varchar(20) not null
  25. );
  26. --新建分类信息表
  27. create table scoreInfo
  28. (
  29.        scoreid number primary key,
  30.        scorexh number references stuinfo(stuid),
  31.        scoresubid number references subInfo(subid),
  32.        score number check (score>=0 or score <=100)
  33. );


  34. --向学生表插入数据
  35. insert into stuInfo values(1,'张山','男',to_date('2005-1-2','yyyy-mm-dd'));
  36. insert into stuInfo values(2,'历史','男',to_date('2001-3-6','yyyy-mm-dd'));
  37. insert into stuInfo values(3,'技术','女',to_date('1995-8-2','yyyy-mm-dd'));
  38. insert into stuInfo values(4,'张山','男',to_date('2006-1-22','yyyy-mm-dd'));
  39. insert into stuInfo values(5,'说道','女',to_date('2013-10-2','yyyy-mm-dd'));
  40. insert into stuInfo values(6,'虽然','男',to_date('1996-10-20','yyyy-mm-dd'));
  41. insert into stuInfo values(7,'谈一谈','女',to_date('2005-1-2','yyyy-mm-dd'));
  42. insert into stuInfo values(8,'一样','女',to_date('2005-1-2','yyyy-mm-dd'));
  43. insert into stuInfo values(9,'方法','男',to_date('2006-6-6','yyyy-mm-dd'));
  44. insert into stuInfo values(10,'尺寸','男',to_date('2008-8-8','yyyy-mm-dd'));
  45. --向课程信息表插入数据
  46. insert into subinfo values(1,'数据库');
  47. insert into subinfo values(2,'java');
  48. insert into subinfo values(3,'web开发');
  49. insert into subinfo values(4,'linux维护');
  50. insert into subinfo values(5,'安全维护');
  51. --向分类信息表插入数据
  52. insert into scoreInfo values(1,1,2,50);
  53. insert into scoreInfo values(2,1,3,70);
  54. insert into scoreInfo values(3,2,1,100);
  55. insert into scoreInfo values(4,3,1,80);
  56. insert into scoreInfo values(5,1,1,60);
Copy code






Previous:Oracle creates a new tablespace and user and authorizes user permissions
Next:I got full grades and felt like I wouldn't have to go to class again
Posted on 3/12/2015 10:27:24 AM |
Copied
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com