home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / databases / sybase-faq / part16 < prev    next >
Encoding:
Internet Message Format  |  2004-04-21  |  19.7 KB

  1. Path: senator-bedfellow.mit.edu!dreaderd!not-for-mail
  2. Message-ID: <databases/sybase-faq/part16_1082468590@rtfm.mit.edu>
  3. Supersedes: <databases/sybase-faq/part16_1074677126@rtfm.mit.edu>
  4. Expires: 2 Aug 2004 13:43:10 GMT
  5. References: <databases/sybase-faq/part1_1082468590@rtfm.mit.edu>
  6. X-Last-Updated: 2003/03/02
  7. From: dowen@midsomer.org (David Owen)
  8. Newsgroups: comp.databases.sybase,comp.answers,news.answers
  9. Subject: Sybase FAQ: 16/19 - ASE Section 9 (1 of 3)
  10. Reply-To: dowen@midsomer.org (David Owen)
  11. Followup-To: comp.databases.sybase
  12. Distribution: world
  13. Organization: Midsomer Consultants Inc.
  14. Approved: news-answers-request@MIT.EDU
  15. Keywords: FAQ, DATABASES, SYBASE, ASA, ASE, REP
  16. Originator: faqserv@penguin-lust.MIT.EDU
  17. Date: 20 Apr 2004 13:45:14 GMT
  18. Lines: 507
  19. NNTP-Posting-Host: penguin-lust.mit.edu
  20. X-Trace: 1082468714 senator-bedfellow.mit.edu 579 18.181.0.29
  21. Xref: senator-bedfellow.mit.edu comp.databases.sybase:106214 comp.answers:56960 news.answers:270300
  22.  
  23. Archive-name: databases/sybase-faq/part16
  24. URL: http://www.isug.com/Sybase_FAQ
  25. Version: 1.7
  26. Maintainer: David Owen
  27. Last-modified: 2003/03/02
  28. Posting-Frequency: posted every 3rd month
  29.    A how-to-find-the-FAQ article is posted on the intervening months.
  30.  
  31.                                    Freeware                                    
  32.                                                                                
  33.  
  34.  
  35. Sybase Tech Docs Open Client ASE FAQ
  36.  
  37.  
  38.  
  39. The best place to search for Sybase freeware is Ed Barlow (sqltech@tiac.net)'s
  40. site (http://www.edbarlow.com).   He is likely to spend more time maintaining
  41. his list than I will spend on this.   I will do my best!
  42.  
  43.     9.0      Where is all the code and why does Section 9 suddenly load in a
  44.     reasonable amount of time?
  45.    
  46.     Stored Procedures
  47.    
  48.     9.1.1      sp_freedevice - lists device, size, used and free.
  49.     9.1.2      sp_dos - This procedure graphically displays the scope of a
  50.     object
  51.     9.1.3      sp_whodo - augments sp_who by including additional columns: cpu,
  52.     I/O...
  53.     9.1.4      sp__revroles - creates DDL to sp_role a mirror of your SQL
  54.     Server
  55.     9.1.5      sp__rev_configure - creates DDL to sp_configure a mirror of your
  56.     SQL Server
  57.     9.1.6      sp_servermap - overview of your SQL Server
  58.     9.1.7      sp__create_crosstab - simplify crosstable queries
  59.     9.1.8      sp_ddl_create_table - creates DDL for all user tables in the
  60.     current database
  61.     9.1.9      sp_spaceused_table
  62.     9.1.10    SQL to determine the space used for an index.
  63.     9.1.11    sp_helpoptions - Shows what options are set for a database.
  64.     9.1.12    sp_days - returns days in current month.
  65.     9.1.13    sp__optdiag - optdiag from within isql
  66.     9.1.14    sp_desc - a simple list of a tables' columns
  67.     9.1.15    sp_lockconfig - Displays locking schemes for tables.
  68.    
  69.     Shell Scripts
  70.    
  71.     9.2.1      SQL and sh(1)to dynamically generate a dump/load database
  72.     command.
  73.     9.2.2      update statistics script
  74.    
  75.     Perl/Sybperl
  76.    
  77.     9.3.1      SybPerl - Perl interface to Sybase.
  78.     9.3.2      dbschema.pl - Sybperl script to reverse engineer a database.
  79.     9.3.3      ddl_insert.pl - creates insert DDL for a table.
  80.     9.3.4      int.pl - converts interfaces file to tli
  81.     9.3.5      Sybase::Xfer.pm - Module to transfer data between two servers.
  82.     9.3.6      sybmon.pl - realtime process and lock monitor
  83.     9.3.7      showserver.pl - shows the servers on a particular machine in a
  84.     nice format.
  85.     9.3.8      Collection of Perl Scripts
  86.    
  87.     Sybtcl
  88.    
  89.     9.4.1      Sybtcl - TCL interface to Sybase.
  90.     9.4.2      sybdump - a Tcl script for dumping a database schema to disk
  91.     9.4.3      wisql - graphical sql editor and more
  92.    
  93.     Python
  94.    
  95.     9.5.1      Sybase Module for Python.
  96.    
  97.     Tools, Utilities and Packages
  98.    
  99.     9.6.1      sqsh - a superset of dsql with local variables, redirection,
  100.     pipes and all sorts of goodies.
  101.     9.6.2      lightweight Sybase Access via Win95/NT
  102.     9.6.3      BCPTool - a utility for trasferring data from ASE to another
  103.     (inc. native port to Linux).
  104.    
  105.     'Free' Versions of ASE
  106.    
  107.     The next couple of questions will move to the OS section (real) soon.
  108.    
  109.     9.7.1      How to access a SQL Server using Linux see also Q11.4.6
  110.     9.7.2      Sybase on Linux Linux Penguin
  111.     9.7.3      How to configure shared-memory for Linux
  112.     9.7.4      Sybase now available on Free BSD
  113.    
  114.     Other Sites of Interest
  115.    
  116.     9.8.1      Ed Barlow's collection of Stored Procedures.
  117.    
  118.     9.8.2      Examples of Open Client and Open Server programs -- see Q11.4.14
  119.     .
  120.     9.8.3      xsybmon - an X interface to sp_monitor
  121.  
  122. Sybase Tech Docs Open Client ASE FAQ
  123.  
  124. -------------------------------------------------------------------------------
  125.  
  126. 9.0: Where is all the code and why does Section 9 suddenly load in a reasonable
  127. amount of time?
  128.  
  129. -------------------------------------------------------------------------------
  130.  
  131. This section was in need of a spring clean, and it has now had it. I have
  132. tested all of the stored procs included here against all versions of Sybase
  133. that I have to hand. (11.0.3.3, 11.9.2 and 12.5 on Linux, 11.9.2 and 12 on
  134. Solaris and 11.9.2 and 12 on NT.) If Pablo or the supplier documented that he
  135. had tested it on other versions, then I have included those comments. Just
  136. remember that I did not test them on anything pre-11.0.3.3. If you are still
  137. using them on a pre-11.0.3.3 release (I know of at least one place that is
  138. still running 4.9.2!) then let me know and I will add a suitable comment.
  139.  
  140. I have actually taken the code away and built a set of packages. First and
  141. foremost is the stored proc package, then there is a shell script package, a
  142. perl package and finally there is the archive package, which contains any stuff
  143. specific to non-current releases of ASE.
  144.  
  145. In addition to wrenching out the code I have added some samples of the output
  146. generated by the scripts. It occurred to me that people will be better able to
  147. see if the stored proc does what they want if they can see what it produces.
  148.  
  149. Finally, part of the reason that this is here is so that people can examine the
  150. code and see how other people write stored procs etc. Each stored proc is in a
  151. file of its own so that you can choose which ones you wish to browse on-line
  152. and then cut and paste them without having to go through the hassle of
  153. un-htmling them.
  154.  
  155. Back to top
  156.  
  157. 9.1.1: sp_freedevice
  158.  
  159. -------------------------------------------------------------------------------
  160.  
  161. This script displays the size of the devices configured for a server, together
  162. with the free and used allocations.
  163.  
  164. Get it as part of the bundle (zip or tarball) or individually from here.
  165.  
  166. Output:
  167.  
  168. [30] BISCAY.master.1> sp_freedevice
  169. [30] BISCAY.master.2>> go
  170.  total                 used                  free
  171.  --------------------- --------------------- ---------------------
  172.              950.00 MB             750.00 MB             200.00 MB
  173.  
  174. (1 row affected)
  175.  devname                        size                  used                  free
  176.  ------------------------------ --------------------- --------------------- ---------------------
  177.  db01                                       100.00 MB              72.00 MB              28.00 MB
  178.  db02                                       100.00 MB               0.00 MB             100.00 MB
  179.  log01                                      100.00 MB              51.00 MB              49.00 MB
  180.  master                                      50.00 MB              27.00 MB              23.00 MB
  181.  sysprocsdev                                200.00 MB             200.00 MB               0.00 MB
  182.  tlg01                                      200.00 MB             200.00 MB               0.00 MB
  183.  tmp01                                      200.00 MB             200.00 MB               0.00 MB
  184.  
  185. (7 rows affected, return status = 0)
  186. [31] BISCAY.master.1>
  187.  
  188. Back to top
  189.  
  190. -------------------------------------------------------------------------------
  191.  
  192. 9.1.2: sp_dos
  193.  
  194. -------------------------------------------------------------------------------
  195.  
  196. sp_dos displays the scope of an object within a database. What tables it
  197. references, what other procedures it calls etc. Very useful for trying to
  198. understand an application that you have just inherited.
  199.  
  200. Get it as part of the bundle (zip or tarball) or individually from here.
  201.  
  202. The output looks like this:
  203.  
  204. 1> sp_dos sp_helpkey
  205. 2> go
  206.  
  207. ** Utility by David Pledger, Strategic Data Systems, Inc.  **
  208. **         PO Box 498, Springboro, OH  45066               **
  209.  
  210.          SCOPE OF EFFECT FOR OBJECT:  sp_helpkey
  211. +------------------------------------------------------------------+
  212. (P) sp_helpkey
  213. |
  214. +--(S) sysobjects
  215. |
  216. +--(S) syskeys
  217. |
  218. +--(P) sp_getmessage
  219.    |
  220.    +--(S) sysusermessages
  221.    |
  222.    +--(P) sp_validlang
  223.  
  224. (return status = 0)
  225. 1>
  226.  
  227. Back to top
  228.  
  229. -------------------------------------------------------------------------------
  230.  
  231. 9.1.3: sp_whodo
  232.  
  233. -------------------------------------------------------------------------------
  234.  
  235. Sybase System 10.x and above
  236.  
  237. sp_whodo is an enhanced version of sp_who, with cpu and io usage for each user.
  238. Note that this proc is now a little out of date since Sybase introduced the fid
  239. column, so subordinate threads are unlikely to be grouped with their parent.
  240.  
  241. Get it as part of the bundle (zip or tarball) or individually from here.
  242.  
  243. Output:
  244.  
  245. 1> sp_whodo
  246. 2> go
  247.  spid   status       loginame     hostname   blk blk_sec program
  248.          dbname  cmd              cpu    io      tran_name
  249.  ------ ------------ ------------ ---------- --- ------- ----------------
  250.         ------- ---------------- ------ ------- ----------------
  251.       2 sleeping     NULL                    0   0
  252.          master  NETWORK HANDLER  0      0
  253.       4 sleeping     NULL                    0   0
  254.          master  DEADLOCK TUNE    0      0
  255.       5 sleeping     NULL                    0   0
  256.          master  MIRROR HANDLER   0      0
  257.       6 sleeping     NULL                    0   0       <astc>
  258.          master  ASTC HANDLER     0      0
  259.       7 sleeping     NULL                    0   0
  260.          master  CHECKPOINT SLEEP 0      128
  261.       8 sleeping     NULL                    0   0
  262.          master  HOUSEKEEPER      0      33
  263.      17 running      sa           n-utsire.m 0   0       ctisql
  264.          master  SELECT           0      1
  265.  
  266. (7 rows affected)
  267.  
  268. Back to top
  269.  
  270. -------------------------------------------------------------------------------
  271.  
  272. 9.1.4: sp__revroles
  273.  
  274. -------------------------------------------------------------------------------
  275.  
  276. Well, I cannot get this one to do what it is supposed to, I am not sure if it
  277. is just that it was written for a different release of Sybase and 11.9.2 and
  278. above has changed the way that roles are built, or what. Anyway, I may work on
  279. it some more.
  280.  
  281. Get it as part of the bundle (zip or tarball) or individually from here.
  282.  
  283. Back to top
  284.  
  285. -------------------------------------------------------------------------------
  286.  
  287. 9.1.5: sp__rev_configure
  288.  
  289. -------------------------------------------------------------------------------
  290.  
  291. This proc reverse engineers the configure settings. It produces a set of calls
  292. to sp_configure for those values that appear in syscurconfigs. I am not sure
  293. how relevant this is with the ability to save and load the config file.
  294.  
  295. Get it as part of the bundle (zip or tarball) or individually from here.
  296.  
  297. The output is as follows, however, I have edited away some of the values since
  298. my list was considerably longer than this.
  299.  
  300.  -- sp_configure settings
  301.  -------------------------------------------------------------
  302.  sp_configure 'recovery interval', 5
  303. go
  304.  sp_configure 'allow updates', 0
  305. go
  306.  sp_configure 'user connections', 25
  307. go
  308.  sp_configure 'memory', 14336
  309. go
  310.  sp_configure 'default character set id', 2
  311. go
  312.  sp_configure 'stack size', 65536
  313. go
  314.  sp_configure 'password expiration interval', 0
  315. go
  316.  sp_configure 'audit queue size', 100
  317. go
  318.  sp_configure 'additional netmem', 0
  319. go
  320.  sp_configure 'default network packet size', 512
  321. go
  322.  sp_configure 'maximum network packet size', 512
  323. go
  324.  sp_configure 'extent i/o buffers',
  325. go
  326.  sp_configure 'identity burning set factor', 5000
  327. go
  328.  sp_configure 'size of auto identity', 10
  329. go
  330.  sp_configure 'identity grab size', 1
  331. go
  332.  sp_configure 'lock promotion threshold', 200
  333. go
  334.  
  335. (41 rows affected)
  336. (return status = 0)
  337.  
  338. Back to top
  339.  
  340. -------------------------------------------------------------------------------
  341.  
  342. 9.1.6: sp_servermap
  343.  
  344. -------------------------------------------------------------------------------
  345.  
  346. A one stop shop for a quick peek at everything on the server.
  347.  
  348. Get it as part of the bundle (zip or tarball) or individually from here.
  349.  
  350. The output for a brand new 11.0.3.3 ASE on Linux server is as follows:
  351.  
  352.                                 Current Date/Time
  353.  ------------------------------ --------------------------
  354.  TRAFALGAR                             Jan 14 2001  1:48PM
  355.  
  356.  Version
  357.  
  358.  -------------------------------------------------------------------------------------------------
  359.  
  360.  SQL Server/11.0.3.3 ESD#6/P-FREE/Linux Intel/Linux 2.2.14 i686/1/OPT/Fri Mar 17 15:45:30 CET 2000
  361.  
  362. A - DATABASE SEGMENT MAP
  363. ************************
  364.  db              dbid   segmap      segs device fragment start (pg)  size (MB)
  365.  --------------- ------ ----------- ---- --------------- ----------- ---------
  366.  master               1           7  LDS master                    4    3.00
  367.  master               1           7  LDS master                 3588    2.00
  368.  tempdb               2           7  LDS master                 2564    2.00
  369.  model                3           7  LDS master                 1540    2.00
  370.  sybsystemprocs       4           7  LDS sysprocsdev        16777216  150.00
  371.  sybsecurity          5          15 ULDS sybsecurity        33554432  300.00
  372.  
  373. Segment Codes:
  374. U=User-defined segment on this device fragment
  375. L=Database Log may be placed on this device fragment
  376. D=Database objects may be placed on this device fragment by DEFAULT
  377. S=SYSTEM objects may be placed on this device fragment
  378.  
  379.  
  380. B - DATABASE INFORMATION
  381. ************************
  382.  db              dbid   size (MB) db status codes    created
  383.          dump tran
  384.  --------------- ------ --------- ------------------ ---------------
  385.         ---------------
  386.  master               1    5.00                      01 Jan 00 00:00
  387.          07 Jan 01 04:01
  388.  tempdb               2    2.00   A                  14 Jan 01 13:46
  389.          14 Jan 01 13:47
  390.  model                3    2.00                      01 Jan 00 00:00
  391.          07 Jan 01 03:38
  392.  sybsystemprocs       4  150.00    B                 07 Jan 01 03:32
  393.          14 Jan 01 13:43
  394.  sybsecurity          5  300.00    B                 07 Jan 01 04:01
  395.          07 Jan 01 04:55
  396.  
  397. Status Code Key
  398.  
  399. Code       Status
  400. ----       ----------------------------------
  401.  A         select into/bulk copy allowed
  402.  B         truncate log on checkpoint
  403.  C         no checkpoint on recovery
  404.  D         db in load-from-dump mode
  405.  E         db is suspect
  406.  F         ddl in tran
  407.  G         db is read-only
  408.  H         db is for dbo use only
  409.  I         db in single-user mode
  410.  J         db name has been changed
  411.  K         db is in recovery
  412.  L         db has bypass recovery set
  413.  M         abort tran on log full
  414.  N         no free space accounting
  415.  O         auto identity
  416.  P         identity in nonunique index
  417.  Q         db is offline
  418.  R         db is offline until recovery completes
  419.  
  420.  
  421. C - DEVICE ALLOCATION MAP
  422. *************************
  423.  device fragment start (pg)  size (MB) db              lstart      segs
  424.  --------------- ----------- --------- --------------- ----------- ----
  425.  master                    4    3.00   master                    0  LDS
  426.  master                 1540    2.00   model                     0  LDS
  427.  master                 2564    2.00   tempdb                    0  LDS
  428.  master                 3588    2.00   master                 1536  LDS
  429.  sybsecurity        33554432  300.00   sybsecurity               0 ULDS
  430.  sysprocsdev        16777216  150.00   sybsystemprocs            0  LDS
  431.  
  432. Segment Codes:
  433. U=USER-definedsegment on this device fragment
  434. L=Database LOG may be placed on this device fragment
  435. D=Database objects may be placed on this device fragment by DEFAULT
  436. S=SYSTEM objects may be placed on this device fragment
  437.  
  438.  
  439. D - DEVICE NUMBER, DEFAULT & SPACE USAGE
  440. ****************************************
  441.  device          vdevno default disk? total (MB) used    free
  442.  --------------- ------ ------------- ---------- ------- -------
  443.  master               0     Y          100.00       9.00   91.00
  444.  sysprocsdev          1     N          150.00     150.00    0.00
  445.  sybsecurity          2     N          300.00     300.00    0.00
  446.  
  447. E - DEVICE LOCATION
  448. *******************
  449.  device          location
  450.  --------------- ------------------------------------------------------------
  451.  master          d_master
  452.  sybsecurity     /d/TRAFALGAR/3/sybsecur.dat
  453.  sysprocsdev     /d/TRAFALGAR/2/sybprocs.dat
  454.  
  455. NO DEVICES ARE MIRRORED
  456. (return status = 0)
  457.  
  458. Back to top
  459.  
  460. -------------------------------------------------------------------------------
  461.  
  462. 9.1.7: sp__create_crosstab
  463.  
  464. -------------------------------------------------------------------------------
  465.  
  466. Hmmm... not quite sure about this one. Was not 100% sure about how to set it
  467. up. From the description it builds a cross tab query. If someone knows how to
  468. use this, then let me know how to set it up and I will improve the description
  469. here and provide some output.
  470.  
  471. Get it as part of the bundle (zip or tarball) or individually from here.
  472.  
  473. Back to top
  474.  
  475. -------------------------------------------------------------------------------
  476.  
  477. 9.1.8: sp_ddl_create_table
  478.  
  479. -------------------------------------------------------------------------------
  480.  
  481. Well, you all know what a create table statement looks like... This produces
  482. the table definitions in their barest form (lacking in constraints etc) and the
  483. resulting DDL is perhaps not as elegant as some other utilities, but far be it
  484. from me to blow dbschema's trumpet :-), but it is worth a look just for the
  485. query. The layout of the carriage returns being embedded within strings is
  486. deliberate!
  487.  
  488. Get it as part of the bundle (zip or tarball) or individually from here.
  489.  
  490. Back to top
  491.  
  492. -------------------------------------------------------------------------------
  493.  
  494. 9.1.9: sp_spaceused_table
  495.  
  496. -------------------------------------------------------------------------------
  497.  
  498. Brief
  499.  
  500. In environment where there are a lot of temporary tables #x being created, how
  501. do you tell who is using how much space ? The answer is sp_spaceused_table,
  502. which basically lists the tables in a database with rowcount and space usage
  503. statistics. I have replaced the original proc with K-shell script for a single
  504. proc. I think that it is easier to compare if it is all in one listing.
  505. However, if you disagree I will add the original code to the archive package,
  506. just let me know.
  507.  
  508. Get it as part of the bundle (zip or tarball) or individually from here.
  509.  
  510. The output of the proc is as follows: (I used sqsh, hence the prompt, since it
  511. auto-resizes its width as you resize the xterm.)
  512.  
  513. [25] N_UTSIRE.tempdb.1> sp_spaceused_table
  514. [25] N_UTSIRE.tempdb.2> go
  515.  name                                          rowtotal    reserved        data            index_size      unused
  516.  --------------------------------------------- ----------- --------------- --------------- --------------- ---------------
  517.  #matter______00000010014294376                12039       3920 KB         3910 KB         0 KB            10 KB
  518.  #synopsis____00000010014294376                6572        15766 KB        274 KB          15472 KB        20 KB
  519.  #hearing_____00000010014294376                5856        572 KB          568 KB          0 KB            4 KB
  520.  #hearing2____00000010014294376                5856        574 KB          568 KB          0 KB            6 KB
  521.  #hearing3____00000010014294376                5856        574 KB          568 KB          0 KB            6 KB
  522.  #synopsis2___00000010014294376                6572        15820 KB        274 KB          15472 KB        74 KB
  523.  
  524. (return status = 0)
  525.  
  526. Back to top
  527.  
  528. -------------------------------------------------------------------------------
  529.  
  530.