Monday 11 April 2011

ASE : ASE commands to play with (for Begineers)

sp_who  -- all current sessions in the ASE server
go

select @@spid -- this is your session
go

select suser_name() -- the username you're logged in with
go

select getdate() -- what's the time?
go

select convert(varchar,getdate(),109)  -- what's the time precisely?
go

sp_helpdb  -- list of databases in this server
go

sp_helpdevice  -- list of the disk files used by this ASE server
go


-- Create your own database to mess around (never create tables etc. in the 'master' database):

create database mydb
go

use mydb
go

select db_name()  -- this should return 'mydb'
go

create table mytab (mycol int, mystring varchar(40), when_added datetime)
go

sp_help
go

sp_help mytab
go

select * from sysobjects where name = 'mytab'
go

insert mytab values (1, 'my first row', getdate())
go
insert mytab values (2, 'my second row', getdate())
go
insert mytab values (3, 'my third -- getting boring now', getdate())
go

select * from mytab
go


-- Create another login:

use master
go

sp_addlogin yourname, yoursecretpassword
go

use mydb
go

sp_adduser yourname  -- needed to get access to database 'mydb'
go


Now log out (or start a new isql session) and log in with the new account:
 isql -U yourname -P yoursecretpassword -Sxxxx
(xxxx is your server's name)

Now do the following:
sp_who  -- all current sessions in the ASE server
go

select @@spid -- this is your session
go

select suser_name() -- the username you're logged in with
go

use mydb
go

select * from mytab
go   

insert mytab values (4, 'my 4th row....', getdate())
go

select * from mytab
go   

No comments:

Post a Comment