-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathview_table.sh
executable file
·57 lines (50 loc) · 1.98 KB
/
view_table.sh
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
#!/bin/bash
LC_ALL=C
shopt -s extglob
clear
source "functions"
source $(pwd)/use_Database.sh
while true; do
echo "Enter Table Name!!!!!!!!!!!"
IFS= read -r table_name
case $table_name in
#validate that the name must have not white spaces..
*\ *)
echo "-----------------------------------------------------------------------"
echo "Invalid Table name!! the name must be without no spaces..!! "
;;
#validate that the name must be letters only..
+([[:digit:]]))
echo "-----------------------------------------------------------------------"
echo "Invalid Table name!! the name must be letters and do not have whitespaces!!!!!"
;;
#the valid regix for name..
+([a-zA-Z]))
#IF table is Exist show the structure...
file_exist ${table_name}
if [ $? -eq 1 ]; then
echo "-----------------------------------------------------------------------"
echo "This are The names of columns in $table_name"
echo "-----------------------------------------------------------------------"
awk 'NR == 2 { print }' $table_name
echo "-----------------------------------------------------------------------"
echo "This is The data type for every column in order of table $table_name"
echo "-----------------------------------------------------------------------"
awk 'NR == 3 { print }' $table_name
echo "-----------------------------------------------------------------------"
echo "This is The data for every column in order of table $table_name"
echo "-----------------------------------------------------------------------"
awk 'NR > 3 { print }' $table_name
echo "-----------------------------------------------------------------------"
break;
else
#IF table is not exist
echo "-----------------------------------------------------------------------"
echo "The table is not exist"
fi
;;
*) echo "Invalid Table name!! name of Table must be lower or upper letters or mix and do not have whitespaces!!!! " ;;
esac
done
cd ..
source DatabaseEngine.sh