-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.cpp
More file actions
131 lines (119 loc) · 2.91 KB
/
menu.cpp
File metadata and controls
131 lines (119 loc) · 2.91 KB
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
#include<iostream>
#include<cstring>
#include<map>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<fstream>
using namespace std;
string op, Table;
string Database;
int use(char* NewDatabase);
void help();
void ShowDatabases();
void CreateDatabase();
void CreateTable();
void ShowTables();
void insert();
void SelectAll();
int main() {
/*cout << "Enter password: ";
string password;
cin >> password;
if (password != "206908") {
cout << "Password Error"<<endl;
return 0;
}
cout << "Welcome to the database operating system. (SQL)" << endl;
cout << "Due to the ability of the producer, the final result is inevitably not satisfactory," << endl;
cout << "hoping you can put forward your valuable comments!" << endl<<endl;
cout << "------------------------------------------------------------------------------------------"<<endl<<endl;
cout << "Before using, please read the following carefully:" << endl;
cout << "Commands end with; or \g." << endl;
cout << "Type 'help; ' or '\\h' for help." << endl;
cout << "Type '\c' to clear the current input statement." << endl;
cout << "Some other content in your use process I will slowly tell you, now please start!" << endl<<endl;
cout << "------------------------------------------------------------------------------------------" << endl;*/
while (1) {
cout << endl << "mysql> ";
cin >> op;
if (op == "\\h" || op == "help" || op == "?") {
help();
}
else if (op == "create") {//创建
string text;
cin >> text;
if (text == "table") {
CreateTable();
}
else if (text == "database") {
CreateDatabase();
}
}
else if (op == "use") {//选择数据库
cin >> Database;
Database = Database.substr(0, Database.size() - 1);
char charDatabase[100];
strcpy(charDatabase, Database.c_str());
int t = use(charDatabase);
if (t == 3) {
cout << "Database changed;";
}
else if (t == 4)continue;
else cout << "Error, the database does not exist";
}
else if (op == "insert") {
string text;
cin >> text;
insert();
}
else if (op == "select") {
string text;
cin >> text;
if (text == "*") {
SelectAll();
}
}
else if (op == "show") {//查看
string text;
cin >> text;
if (text == "tables;") {
ShowTables();
}
else if (text == "databases;") {
ShowDatabases();
}
else if (text == "create") {
cin >> text;
if (text == "database") {
}
else if (text == "table") {
}
}
else if (text == "table") {
//scanf("status from %s", &Database);
}
else if (text == "varblies") {
}
}
else if (op == "drop") {//删除
string text;
cin >> text;
}
else if (op == "desc") {
}
else if (op == "alter") {
}
else if (op == "rename") {
}
else if (op == "update") {
}
else if (op == "delete") {
}
else if (op == "exit") return 0;
else cout << "Unrecognized operation or instruction";
}
}