Guest User

sql stuff

a guest
May 5th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. --Initial scripts to run
  2.  
  3. --recreate thesis with pre-filled values
  4. drop table app.thesis;
  5. CREATE TABLE app.THESIS (thesisid INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), USERNAME VARCHAR(128) NOT NULL, COURSENUM INTEGER NOT NULL,
  6. LIVELINK VARCHAR(256),KEYWORDS VARCHAR(256), ABSTRACT VARCHAR(1024), ZIPFILE VARCHAR(256), SCREENCAST VARCHAR(256), COMMITTEE VARCHAR(1024), SEMESTER VARCHAR(128),
  7. DATEUPLOADED VARCHAR(10), views integer default 0, downloads integer default 0, CONSTRAINT thesisid PRIMARY KEY (thesisid));
  8. INSERT INTO APP.THESIS (USERNAME, COURSENUM, LIVELINK, KEYWORDS, ABSTRACT, ZIPFILE, SCREENCAST, COMMITTEE, SEMESTER, DATEUPLOADED)
  9. VALUES ('Austin Savage', 353, 'https://google.com/', 'test, example, demo, thesis', 'This is an example post of a thesis. This is where the abstract will show up.', '/1/file.zip', 'https://youtube.com/', 'Austin Savage, Andrew Smith', 'Spring 2015', '04-22-2015');
  10. INSERT INTO APP.THESIS (USERNAME, COURSENUM, LIVELINK, KEYWORDS, ABSTRACT, ZIPFILE, SCREENCAST, COMMITTEE, SEMESTER, DATEUPLOADED)
  11. VALUES ('Andrew Smith', 353, 'https://reddit.com/', 'test, upload, hello,', 'This is an example post of a thesis. This is where the abstract will show up.', '/2/file.zip', 'https://illinoisstate.edu/', 'Andrew Smith, Austin Savage', 'Spring 2015', '04-23-2015');
  12. INSERT INTO APP.THESIS (USERNAME, COURSENUM, LIVELINK, KEYWORDS, ABSTRACT, ZIPFILE, SCREENCAST, COMMITTEE, SEMESTER, DATEUPLOADED)
  13. VALUES ('Austin Savage', 367, 'https://google.com/', 'test, example, app, georgia', 'This is an example post of a thesis. This is where the abstract will show up.', '/3/file.zip', 'https://youtube.com/', 'Austin Savage, Andrew Smith, Dr. Lim', 'Spring 2015', '04-27-2015');
  14. select * from app.thesis;
  15. --create users table with pre-filled values
  16. drop table app.users;
  17. CREATE TABLE app.USERS (userid INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), FIRSTNAME VARCHAR(25) NOT NULL,
  18. LASTNAME VARCHAR(25) NOT NULL, PASSWORD VARCHAR(25) NOT NULL, EMAIL VARCHAR(25) NOT NULL, SECURITYQ VARCHAR(128) NOT NULL, SECURITYA VARCHAR(128) NOT NULL,
  19. REASON VARCHAR(128) NOT NULL, USERNAME VARCHAR(25) NOT NULL, APPROVED BOOLEAN DEFAULT false , ISADMIN BOOLEAN default false, loginCounter integer default 0,
  20. uploadCounter integer default 0, CONSTRAINT userid PRIMARY KEY (userid));
  21. insert into app.users (firstname,lastname,password,email,securityq,securitya,reason,username,approved,isadmin)
  22. values('The','Admin','password','ajsmit2@ilstu.edu','What is your favorite color?','Red','Bc admin.','admin',true,true);
  23. select * from app.users;
  24. --to increment view counters
  25. update app.thesis set views = views + 1 where thesisid = ?
  26. update app.thesis set downloads = downloads + 1 where thesisid = ?
  27. update app.users set loginCounter = loginCounter + 1 where userid = ?
  28. update app.users set uploadCounter = uploadCounter + 1 where userid = ?
Add Comment
Please, Sign In to add comment