forked from sharfah/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.sqshrc
66 lines (55 loc) · 1.23 KB
/
.sqshrc
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
\set histsize=20
\set keyword_completion=smart
\set history_shorthand=on
\set banner=false
\set histsave=true
\set histunique=true
\set prompt_color='{1;33}'
\set text_color='{0;37}'
\set prompt='${prompt_color}[$histnum][$username@$DSQUERY.$database] $lineno >$text_color '
\set prompt2='${prompt_color}[sqsh]-->$text_color '
\alias h='\history'
# Functions
# turns io and time stats on/off
\func -x stats
\if [ $# -ne 1 ]
\echo "usage: stats [on | off]"
\return 1
\fi
set statistics io ${1}
set statistics time ${1}
go
\done
# turns plan on/off
\func -x plan
\if [ $# -eq 0 ]
\echo "usage: plan [on | off]"
\return 1
\fi
set showplan ${1}
go
\done
# shortcut for select * from
\func -x sf
\if [ $# -eq 0 ]
\echo 'usage: sf "[table [where ...]]"'
\return 1
\fi
select * from $*; | less -F
\done
# returns top 10 rows of a table
\func -x head
\if [ $# -eq 0 ]
\echo 'usage: head "[table [where ...]]"'
\return 1
\fi
select top 10 * from $*;
\done
# count rows in a table
\func -x count
\if [ $# -eq 0 ]
\echo 'usage: count "[table [where ...]]"'
\return 1
\fi
select count(*) from $*;
\done