-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
145 lines (138 loc) · 4 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// project: SQL queries? CLI App
var readlineSync = require('readline-sync')
var score = 0
var SQLquestions = [
{
question:"Which of the following are some common RDBMS in use?",
option: ['Oracle','MySQL','HeidiSQL','All of the above'],
answer: 3
},
{
question:'What command is used to create a new table in SQL?',
option: ['CREATE TABLE', 'BUILD TABLE', 'GENERATE TABLE', 'None of the above'],
answer: 0
},
{
question:'What does the following sttement in SQL do \n DROP TABLE student',
option: ['Delete a table called student.',
'Creates a table called student.',
'Check if there is a table called student.',
'None of the above.'
],
answer: 0
},
{
question:'Which of the following are types of Unicode character string types in SQL?',
option: ['nchar','ntext','Both A and B','None of the above'],
answer:2
},
{
question:'What does BLOB in SQL stand for?',
option: [
'Binary Large Objects',
'Big Large Objects',
'Binary Language for Objects',
'None of the above'
],
answer: 0
},
{
question:'Which of the following datatype is most appropriate for storing a string of up to 255 characters?',
option: ['TEXT', 'TINY TEXT', 'BLOB', 'BINARY'],
answer: 1
},
{
question:'What happens when no value is inserted in an ENUM list?',
option: [
'Nothing happens',
'The code will crash',
'A blank value is inserted in that case',
'None of the above'
],
answer:2
},
{
question:'What is the range of integers that can be held in the MEDIUMINT datatype of SQL?',
option: [
'Signed number in the range of -8388608 to 8388607',
'Unsigned number in the range of 0 to 16777215',
'Both A and B',
'None of the above'
],
answer: 2
},
{
question:'What does the following code snippet do? \n ALTER TABLE SUDENT ADD(ADDRESS VARCHAR2(20));',
option: [
'Adds a column called ADDRESS in the table student.',
'Checks if a column called ADDRESS is present in the table student.',
'Invalid Syntax',
'None of the above'
],
answer:0
},
{
question:'Which of the following commands is used to delete all rows and free up space from a table?',
option: ['TRUNCATE', 'DROP', 'DELETE', 'ALTER'],
answer: 0
},
{
question:'Which of the following commands are a part of Data Control Language?',
option: ['Revoke','Grant','Both 1 and 2','None of the above'],
answer:2
},
{
question:'What does the following code snippet do?\
DELETE FROM STUDENTS \
WHERE AGE = 16; \
ROLLBACK;',
option: [
'Performs an undo operation on the delete operation',
'Deletes the rows from the table where AGE = 16',
'Deletes the entire table',
'None of the above'
],
answer:0
},
{
question:'When is the wildcard in WHERE clause used?',
option: [
'An exact match is necessary for a CREATE statement',
'An exact match is not possible in a SELECT statement',
'An exact match is necessary for a SELECT statement',
'None of the above'
],
answer:1
},
{
question:'Which of the following is the full form of DDL?',
option: [
'Data definition language',
'Data derivation language',
'Dynamic data language',
'Detailed data language'
],
answer:0
},
{
question:'Which SQL constraint do we use to set some value to a field whose value has not been added explicitly?',
option: ['UNIQUE','NOT NULL','DEFAULT','CHECK'],
answer:2
}
]
function quiz(Qlist){
for (var i = 0; i < Qlist.length; i++){
console.log(String(i+1) + '. ' + Qlist[i].question)
var userAns = readlineSync.keyInSelect(Qlist[i].option,"")
if(userAns == Qlist[i].answer){
console.log("CORRECT :) \n")
score++
}
else{
console.log("OOPS!!! \n")
}
}
}
userName = readlineSync.question("What's your name? ")
quiz(SQLquestions)
console.log(userName + " you scored = " + score)