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

  1. Path: senator-bedfellow.mit.edu!dreaderd!not-for-mail
  2. Message-ID: <databases/sybase-faq/part17_1082468590@rtfm.mit.edu>
  3. Supersedes: <databases/sybase-faq/part17_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: 17/19 - ASE Section 9 (2 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:15 GMT
  18. Lines: 1580
  19. NNTP-Posting-Host: penguin-lust.mit.edu
  20. X-Trace: 1082468715 senator-bedfellow.mit.edu 580 18.181.0.29
  21. Xref: senator-bedfellow.mit.edu comp.databases.sybase:106215 comp.answers:56961 news.answers:270301
  22.  
  23. Archive-name: databases/sybase-faq/part17
  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. 9.1.10: SQL to determine space used for an index
  32.  
  33. -------------------------------------------------------------------------------
  34.  
  35. This one is not strictly a stored proc, but it has its uses.
  36.  
  37. Fundamentally, it is sp_spaceused reduced to bare essentials:
  38.  
  39.   set nocount on
  40.   declare @objname varchar(30)
  41.   select  @objname = "your table"
  42.  
  43.   select  index_name = i.name,
  44.           i.segment,
  45.           rowtotal   = rowcnt(i.doampg),
  46.           reserved   = reserved_pgs(i.id, i.doampg) +
  47.                        reserved_pgs(i.id, i.ioampg),
  48.           data       = data_pgs(i.id, i.doampg),
  49.           index_size = data_pgs(i.id, i.ioampg),
  50.           unused     = (reserved_pgs(i.id, i.doampg) +
  51.                         reserved_pgs(i.id, i.ioampg) -
  52.                           (data_pgs(i.id, i.doampg) +
  53.                            data_pgs(i.id, i.ioampg)))
  54.   into    #space
  55.   from    sysindexes i
  56.   where   i.id = object_id(@objname)
  57.  
  58. You can analyse this in a number of ways:
  59.  
  60.  1. This query should tally with sp_spaceused @objname:
  61.       select 'reserved KB' = sum(reserved)   * 2,
  62.              'Data KB'     = sum(data)       * 2,
  63.              'Index KB'    = sum(index_size) * 2,
  64.              'Unused KB'   = sum(unused)     * 2
  65.         from #space
  66.  2. This one reports space allocation by segment:
  67.       select 'segment name' = s.name,
  68.              'reserved KB'  = sum(reserved)   * 2,
  69.              'Data KB'      = sum(data)       * 2,
  70.              'Index KB'     = sum(index_size) * 2,
  71.              'Unused KB'    = sum(unused)     * 2
  72.         from #space t,
  73.              syssegments s
  74.        where t.segment = s.segment
  75.        group by s.name
  76.  3. This one reports allocations by index:
  77.       select  t.index_name,
  78.                   s.name,
  79.                   'reserved KB' = reserved * 2,
  80.                   'Data KB' = data * 2,
  81.                   'Index KB' = index_size * 2,
  82.                   'Unused KB' = unused * 2
  83.           from    #space t,
  84.                   syssegments s
  85.           where   t.segment = s.segment
  86.  
  87. If you leave out the where clause in the initial select into, you can analyse
  88. across the whole database.
  89.  
  90. Hope this points you in the right direction.
  91.  
  92. Back to top
  93.  
  94. -------------------------------------------------------------------------------
  95.  
  96. 9.1.11: sp_helpoptions - Shows what options are set for a database.
  97.  
  98. -------------------------------------------------------------------------------
  99.  
  100. Thanks again go to Bret Halford for some more sterling work. The following proc
  101. will let you know some of options that are set within a database. The release
  102. included is here has been tested to work on Solaris (11.9.2 and 12.0), but it
  103. is likely that other platforms use and set @@options differently (endian issues
  104. etc). As such, it is more of a sort of template for platforms other than
  105. Solaris. Please feel free to expand it and send the modified proc back to me
  106. and Bret.
  107.  
  108. Get it as part of the bundle (zip or tarball) or individually from here.
  109.  
  110. The output is as follows:
  111.  
  112. 1> sp_helpoptions
  113. 2> go
  114. showplan is off
  115. ansinull is off
  116. ansi_permissions is off
  117. arithabort is on
  118. arithignore is off
  119. arithignore arith_overflow off
  120. close on endtran is off
  121. nocount is on
  122. noexec is off
  123. parseonly is off.
  124. (return status = 0)
  125.  
  126. Back to top
  127.  
  128. -------------------------------------------------------------------------------
  129.  
  130. 9.1.12: sp_days - returns days in a given month.
  131.  
  132. -------------------------------------------------------------------------------
  133.  
  134. Returns the number of days in a month. Modify to fit your needs, either
  135. returning a result set (of 1 row) or set a variable, or both as this version
  136. does.
  137.  
  138. Get it as part of the bundle (zip or tarball) or individually from here.
  139.  
  140. The output is as follows:
  141.  
  142. 1> declare @days int
  143. 2> -- For November 1999
  144. 3> exec sp_days @days,11,99
  145. 4> go
  146.  
  147.  ---
  148.   30
  149.  
  150. (1 row affected)
  151. (return status = 0)
  152.  
  153. Back to top
  154.  
  155. -------------------------------------------------------------------------------
  156.  
  157. 9.1.13: sp__optdiag - optdiag from within isql.
  158.  
  159. -------------------------------------------------------------------------------
  160.  
  161. Versions of ASE: minimum of 11.5. I cannot test it on 11.5, so I do not know if
  162. it works on that version. However, the procedure uses a 'case' statement, so
  163. will certainly not work before 11.5. If anyone still has 11.5 running and can
  164. let me know that it works, I would be grateful.
  165.  
  166. It seems little point in showing you what optdiag looks like, since it takes a
  167. fair amount of space. This proc produces pretty much identical output.
  168.  
  169. Get it as part of the bundle (zip or tarball) or individually from here.
  170.  
  171. Back to top
  172.  
  173. -------------------------------------------------------------------------------
  174.  
  175. 9.1.14: sp_desc - a simple list of a tables' columns
  176.  
  177. -------------------------------------------------------------------------------
  178.  
  179. Stored proc to return a much simpler picture of a table that sp_help.  sp_help
  180. produces all of the information, too much in fact, and it always takes me a
  181. couple of minutes to work out the various flags etc.  I think that this is a
  182. little easier to read and understand quickly.
  183.  
  184. 1> sp_desc spt_values
  185. 2> go
  186. spt_values
  187. No.   Column Name                    Datatype
  188. ----- ------------------------------ -------------------- --------
  189. (1)   name                           varchar(28)
  190. (2)   number                         int                  NOT NULL
  191. (3)   type                           char(2)              NOT NULL
  192. (4)   low                            int
  193. (5)   high                           int
  194. (6)   msgnum                         int
  195.  
  196. (6 rows affected)
  197. (return status = 0)
  198. 1>
  199.  
  200. Get it as part of the bundle (zip or tarball) or individually from here.
  201.  
  202. Back to top
  203.  
  204. -------------------------------------------------------------------------------
  205.  
  206. 9.1.15: sp_lockconfig - displays locking schemes for tables
  207.  
  208. -------------------------------------------------------------------------------
  209. sp_lockconfig [sys_flag]
  210. will list the server default locking scheme and lock promotion data (HWM, LWM,
  211. and PCT) in priority order: 
  212.  
  213.  1. All table-specific lock configurations for the current database. 
  214.  2. The database-wide lock configurations, if they exist. 
  215.  3. The server-wide lock configurations. 
  216.  
  217. A list of all tables will then be listed by locking scheme. For data-only
  218. tables a suffix of "*" indicates that the table was originally created with a
  219. clustered allpages configuration and was then altered to a data-only
  220. configuration. (The reverse cannot be detected.) If sys_flag is non-null then
  221. system tables will be included. Note that many system tables do not have a
  222. defined locking scheme. (The implicit usage is allpages.)
  223.  
  224. 1> sp_lockconfig
  225. 2> go
  226.  
  227.  TYPE     OBJECT                       LEVEL LOCK DATA
  228.  -------- ---------------------------- ----- ---------------------------------
  229.  Server   -                            page  PCT = 100, LWM = 200, HWM = 200
  230.  Server   -                            row   PCT = 100, LWM = 200, HWM = 200
  231.  Server   default lock scheme          -     allpages
  232.  
  233.     THERE ARE 4 USER TABLES WITH ALLPAGES LOCKING.
  234.  
  235.  TABLE                          OWNER
  236.  ------------------------------ ------------------------------
  237.  appkey8                        dbo
  238.  appkey8_hist                   dbo
  239.  text_table7                    TESTUSER2
  240.  with_types_table12             TESTUSER3
  241.  
  242.     THERE ARE 2 USER TABLES WITH DATAPAGES LOCKING.
  243.  
  244.  TABLE                          OWNER
  245.  ------------------------------ ------------------------------
  246.  dol_test1                      dbo
  247.  dol_test2                      dbo
  248.  
  249.     THERE ARE 2 USER TABLES WITH DATAROWS LOCKING.
  250.  
  251.  TABLE                          OWNER
  252.  ------------------------------ ------------------------------
  253.  dol_test10                     dbo
  254.  dol_test11                     dbo
  255.  
  256. (return status = 0)
  257. 1>
  258.  
  259. Get it as part of the bundle (zip or tarball) or individually from here.
  260.  
  261. Back to top
  262.  
  263. -------------------------------------------------------------------------------
  264.  
  265. 9.2.1: Generating dump/load database command.
  266.  
  267. -------------------------------------------------------------------------------
  268.  
  269. This shell script generates dump/load database commands from dump devices. I
  270. cannot show the output because it seems to be broken, it is certainly a little
  271. convoluted and is really pertinent to the pre-11 days, possibly even pre-10. It
  272. is available as part of the archive code package.
  273.  
  274. What is really needed here is some automatic backup scripts. How is it going
  275. Barb?
  276.  
  277. Get it as part of the bundle (zip or tarball) or individually from here.
  278.  
  279. Back to top
  280.  
  281. -------------------------------------------------------------------------------
  282.  
  283. 9.2.2: upd_stats.csh
  284.  
  285. -------------------------------------------------------------------------------
  286.  
  287. This is a script from Frank Lundy (mailto:flundy@verio.net) and does not
  288. generate output, but does the updates directly. As such there is no output to
  289. show you. It requires a program called sqlsa which you will need to modify to
  290. suit your own server.  You probably want to make the file unreadable by regular
  291. users who have no need for any passwords contained within.
  292.  
  293. Get it as part of the bundle (zip or tarball) or individually from here.
  294.  
  295. Back to top
  296.  
  297. -------------------------------------------------------------------------------
  298.  
  299. 9.3.1: SybPerl FAQ
  300.  
  301. Sybperl is a fantastic utility for DBAs and system administrators needing to
  302. put together scripts to monitor and manage their installations as well as the
  303. main way that web developers can gain access to data held in ASEs.
  304.  
  305. Sybperl now comes in a number of flavours, including a DBD version that is part
  306. of the DBI/DBD suite. Michael has also written a package called Sybase::Simple
  307. that sits on top of Sybperl that makes building such scripts a breeze.
  308.  
  309. Find out more and grab a copy from Michael Peppler's mpeppler@peppler.org own
  310. FAQ:
  311.  
  312. http://www.mbay.net/~mpeppler/Sybperl/sybperl-faq.html
  313.  
  314. Back to top
  315.  
  316. -------------------------------------------------------------------------------
  317.  
  318. 9.3.2: dbschema.pl
  319.  
  320. -------------------------------------------------------------------------------
  321.  
  322. dbschema.pl is a script that will extract the schema (everything from the
  323. server definition down to table permissions etc) from ASE/SQL Server.  It was
  324. initially developed by Michael Peppler but currently maintained by me (David
  325. Owen dowen@midsomer.org)  The script is written using Sybperl and was
  326. originally distributed solely as part of that package.  The latest copy can be
  327. got from ftp://ftp.midsomer.org/pub/dbschema.tgz.
  328.  
  329. Back to top
  330.  
  331. -------------------------------------------------------------------------------
  332.  
  333. 9.3.3: ddl_insert.pl
  334.  
  335. -------------------------------------------------------------------------------
  336.  
  337. In order to use this script you must have Sybperl installed -- see Q9.3.1 for
  338. more information.
  339.  
  340. This utility produces the insert statements to rebuild a table. Note that it
  341. depends on the environment variable DSQUERY for the server selection. Also be
  342. warned that the generated script truncates the destination table, which might
  343. not be what you want. Other than that, it looks like an excellent addition to
  344. the testing toolkit.
  345.  
  346. Get it as part of the bundle (zip or tarball) or individually from here.
  347.  
  348. [dowen@n-utsire code]$ ./ddl_insert.pl alrbprod sa myPassword h%
  349. -- This script is created by ./ddl_insert.pl.
  350. -- It would generate INSERT statements for tables whose names match the
  351. -- following pattern:
  352. /*      (  1 = 0
  353.      or name like 'h%'
  354.         )
  355.  
  356. */
  357.  
  358. set nocount on
  359. go
  360.  
  361.  
  362. /*.............. hearing ...............*/
  363. -- Sat Feb 17 13:24:09 MST 2001
  364.  
  365. declare @d datetime
  366. select @d = getdate()
  367. print        '       %1!    hearing', @d
  368. go
  369.  
  370. truncate table hearing  -- Lookout !!!!!!
  371. go
  372.  
  373. insert hearing values('Dec 11 1985 12:00:00:000AM', 1, '1030', 2, '0930', 'Calgary, Alberta', NULL, NULL, '3408 Board Room', 3, NULL, '35', NULL)
  374. ...
  375.  
  376. Back to top
  377.  
  378. -------------------------------------------------------------------------------
  379.  
  380. 9.3.4: int.pl
  381.  
  382. -------------------------------------------------------------------------------
  383.  
  384. Background
  385.  
  386. Please find included a copy of int.pl, the interfaces file conversion tool. It
  387. should work with perl 4 and 5, but some perl distributions don't seem to
  388. support gethostbyname which you need for the solaris, ncr, and vms file format.
  389.  
  390. You may need to adjust the first line to the path of perl on your system, and
  391. may need to set the PERLLIB environment variable so that it finds the
  392. getopts.pl module.
  393.  
  394. While it may not be 100% complete (e.g. it ignores the timeout field) you're
  395. free to add any functionality you may need at your site.
  396.  
  397. int.pl -h will print the usage, typical invocation is
  398.         int.pl -f sun4-interfaces -o sol > interfaces.sol
  399. Usage:  int.pl  -f 
  400.                 -o { sol|ncr|vms|nw386|os2|nt386|win3|dos|ntdoswin3 }
  401.                 [-V] [-v] [-h]
  402. where
  403.         -f  input file to process
  404.         -o  specify output mode
  405.                   (e.g. sol, ncr, vms, nw386, os2, nt386, win3, dos, ntdoswin3)
  406.         -V        turn on verbose mode
  407.         -v        print version string
  408.         -h        print this message
  409.  
  410. [The following are a couple of output examples, is any other utility ever
  411. needed? Ed]
  412.  
  413. Get it as part of the bundle (zip or tarball) or individually from here.
  414.  
  415. The following interface file:
  416.  
  417. N_UTSIRE
  418.         master tcp ether n-utsire 4100
  419.         query tcp ether n-utsire 4100
  420.  
  421. N_UTSIRE_XP
  422.         master tcp ether n-utsire 4400
  423.         query tcp ether n-utsire 4400
  424.  
  425. N_UTSIRE_BS
  426.         master tcp ether n-utsire 4010
  427.         query tcp ether n-utsire 4010
  428.  
  429.  
  430. becomes
  431.  
  432. [dowen@n-utsire code]$ ./int.pl -f $SYBASE/interfaces -o vms
  433. N_UTSIRE
  434.         master tcp ether 192.168.1.1 4100
  435.         query tcp ether 192.168.1.1 4100
  436. N_UTSIRE_XP
  437.         master tcp ether 192.168.1.1 4400
  438.         query tcp ether 192.168.1.1 4400
  439. N_UTSIRE_BS
  440.         master tcp ether 192.168.1.1 4010
  441.         query tcp ether 192.168.1.1 4010
  442. [dowen@n-utsire code]$
  443. [dowen@n-utsire code]$ ./int.pl -f $SYBASE/interfaces -o sol
  444. N_UTSIRE
  445.         master tli tcp /dev/tcp \x00021004c0a801010000000000000000
  446.         query tli tcp /dev/tcp \x00021004c0a801010000000000000000
  447. N_UTSIRE_XP
  448.         master tli tcp /dev/tcp \x00021130c0a801010000000000000000
  449.         query tli tcp /dev/tcp \x00021130c0a801010000000000000000
  450. N_UTSIRE_BS
  451.         master tli tcp /dev/tcp \x00020faac0a801010000000000000000
  452.         query tli tcp /dev/tcp \x00020faac0a801010000000000000000
  453. [dowen@n-utsire code]$
  454. [dowen@n-utsire code]$ ./int.pl -f $SYBASE/interfaces -o ncr
  455. N_UTSIRE
  456.         master tli tcp /dev/tcp \x00021004c0a80101
  457.         query tli tcp /dev/tcp \x00021004c0a80101
  458. N_UTSIRE_XP
  459.         master tli tcp /dev/tcp \x00021130c0a80101
  460.         query tli tcp /dev/tcp \x00021130c0a80101
  461. N_UTSIRE_BS
  462.         master tli tcp /dev/tcp \x00020faac0a80101
  463.         query tli tcp /dev/tcp \x00020faac0a80101
  464. [dowen@n-utsire code]$
  465.  
  466. Back to top
  467.  
  468. -------------------------------------------------------------------------------
  469.  
  470. 9.3.5: Sybase::Xfer.pm
  471.  
  472. -------------------------------------------------------------------------------
  473.  
  474. The following is taken directly from the authors own documentation.
  475.  
  476. QUICK DESCRIPTION
  477.  Sybase::Xfer transfers data between two Sybase  servers  with  multiple
  478.  options like specifying a where_clause, a smart auto_delete option  and
  479.  can pump data from a perl subroutine or take a  plain  flat  file.  Has
  480.  option, similiar to default behaviour in Sybase::BCP, to capture failed
  481.  rows in a batch.
  482.  
  483.  Also comes with a command line wrapper, sybxfer.
  484.  
  485.  Also comes with a sister module Sybase::ObjectInfo.pm
  486.  
  487.  
  488. DEPENDENCIES
  489.    Requires Perl Version 5.005 or beyond
  490.  
  491.    Requires packages:
  492.       Sybase::DBlib
  493.       Getopt::Long
  494.       Tie::IxHash
  495.  
  496.  
  497. SYNOPSIS
  498.    #from perl
  499.       #!/usr/bin/perl5.005
  500.       use Sybase::Xfer;
  501.       $h = new Sybase::Xfer( %options );
  502.       $h->xfer();
  503.       $h->done();
  504.  
  505.    #from shell
  506.       #!/usr/ksh
  507.       sybxfer <options>
  508.  
  509.  
  510. DESCRIPTION (a little bit from the pod)
  511.  
  512.   If you're in an environment with multiple servers and you  don't  want
  513.   to use cross-server joins then this module may be worth a  gander.  It
  514.   transfers data from one server to another server row-by-row in memory
  515.   w/o using an intermediate file.
  516.  
  517.   To juice things up it can take data from any set of  sql  commands  as
  518.   long as the output of the sql matches the  definition  of  the  target
  519.   table. And it can take data from a  perl  subroutine  if  you're  into
  520.   that.
  521.  
  522.   It also has some smarts to delete rows in the target table before  the
  523.   data is  transferred  by  several  methods.  See  the  -truncate_flag,
  524.   -delete_flag and -auto_delete switches.
  525.  
  526.   Everything is controlled by switch settings sent has  a  hash  to  the
  527.   module. In essence one describes the from source and the to source and
  528.   the module takes it from there.
  529.  
  530.   Error handling:
  531.  
  532.     An attempt was made to build in hooks for robust error reporting via
  533.     perl callbacks. By default, it will print to stderr  the  data,  the
  534.     column names, and their datatypes upon  error.  This  is  especially
  535.     useful when sybase reports attempt to load an oversized row  warning
  536.     message.
  537.  
  538.  
  539.   Auto delete:
  540.  
  541.     More recently the code has been  tweaked  to  handle  the  condition
  542.     where data is bcp'ed into a table but the row already exists and the
  543.     desired result to replace  the  row.  Originally,  the  -delete_flag
  544.     option was meant for this condition. ie. clean out the table via the
  545.     -where_clause before the bcp in was to occur. If this is  action  is
  546.     too drastic, however, by using the -auto_delete option  one  can  be
  547.     more precise and force only those rows about to be  inserted  to  be
  548.     deleted before the bcp in begins. It will bcp the 'key'  information
  549.     to a temp table, run a delete (in a loop so as not to blow  any  log
  550.     space) via a join between the temp table and target table  and  then
  551.     begin the bcp in. It's weird but in the right situation  it  may  be
  552.     exactly what you want. Typically used to manually replicate a table.
  553.  
  554.  
  555. CONTACTS
  556.    my e-mail: stephen.sprague@msdw.com
  557.  
  558. Back to top
  559.  
  560. -------------------------------------------------------------------------------
  561.  
  562. 9.3.6: Sybmon.pl
  563.  
  564. -------------------------------------------------------------------------------
  565.  
  566. Sybmon is a utility for interactive, realtime, monitoring of processes and
  567. locks. It is a sort of "top" for Sybase. It requires both Sybperl and Perl/Tk
  568. to be installed, both are available for most platforms, including Linux, NT,
  569. Solaris.
  570.  
  571. Grab the tarball from ftp://ftp.midsomer.org/pub/sybmon.tar.gz or a zip'd one
  572. from ftp://ftp.midsomer.org/pub/sybmon.zip.
  573.  
  574. There is also an NT binary for those people that are unable or just don't want
  575. to install Perl.  You can get that from ftp://ftp.midsomer.org/pub/
  576. sybmon-i386.zip.
  577.  
  578. You can view a screenshot of the main process monitor from here (just to prove
  579. that it runs on NT fine!!!!). A not very exciting server, doing not a lot!
  580.  
  581. A note of interest! To get the screenshot I used the latest copy of Activestate
  582. Perl for NT and their Perl Package Manager (just type PPM from a DOS prompt
  583. once Perl is installed) and had the 3 required packages (Tk, Sybperl, Sybase::
  584. Login) installed in under 2 minutes!!!!
  585.  
  586. Back to top
  587.  
  588. -------------------------------------------------------------------------------
  589.  
  590. 9.3.7: showserver.pl
  591.  
  592. -------------------------------------------------------------------------------
  593.  
  594. This small Perl script shows a list of what servers are running on the current
  595. machine.  Does a similar job to the showserver that comes with ASE, but looks
  596. much nicer.
  597.  
  598. Get it as part of the bundle (zip or tarball) or individually from here.
  599.  
  600. bash-2.03$ ./showserver.pl
  601.  
  602. monserver's
  603. -----------
  604.   CONCRETE Owner: sybase, Started: 14:25:51
  605.       Engine:  0 (PID: 520)
  606.   PORTLAND Owner: sybase, Started: 14:29:33
  607.       Engine:  0 (PID: 545)
  608.  
  609. dataserver's
  610. ------------
  611.   CONCRETE Owner: sybase, Started: 14:10:38
  612.       Engine:  1 (PID: 494)
  613.       Engine:  0 (PID: 493)
  614.   PORTLAND Owner: sybase, Started: 14:26:56
  615.       Engine:  0 (PID: 529)
  616.  
  617. backupserver's
  618. --------------
  619.   CONCRETE_back Owner: sybase, Started: 14:25:25
  620.       Engine:  0 (PID: 515)
  621.   PORTLAND_back Owner: sybase, Started: 14:29:07
  622.       Engine:  0 (PID: 538)
  623.  
  624. Back to top
  625.  
  626. -------------------------------------------------------------------------------
  627.  
  628. 9.3.8: Collection of Perl Scripts
  629.  
  630. -------------------------------------------------------------------------------
  631.  
  632. David Whitmarsh has put together a collection of scripts to help manage and
  633. monitor ASEs. They can be grabbed individually or en masse from http://
  634. sparkle-consultancy.co.uk/sybase/ .
  635.  
  636. Back to top
  637.  
  638. -------------------------------------------------------------------------------
  639.  
  640. 9.4.1: Sybtcl FAQ
  641.  
  642. This is Tom Poindexter http://www.nyx.net/~tpoindex/ FAQ.
  643.  
  644. -------------------------------------------------------------------------------
  645.  
  646.                                Index of Sections                               
  647.                                                                                
  648.   * Overview
  649.   * The enabling language platform
  650.   * Design and commands
  651.   * Applications
  652.   * Information Sources
  653.   * Download
  654.   * About the Author
  655.  
  656. -------------------------------------------------------------------------------
  657.  
  658.                                    Overview                                    
  659.                                                                                
  660. Sybtcl is an extension to Tcl (Tool Command Language) that allows Tcl programs
  661. to access Sybase databases. Sybtcl adds additional Tcl commands to login to a
  662. Sybase server, send SQL statements, retrieve result sets, execute stored
  663. procedures, etc. Sybtcl simplifies Sybase programming by creating a high level
  664. interface on top of DB-Library. Sybtcl can be used to program a wide variety of
  665. applications, from system administration procedures to end-user applications.
  666.  
  667. Sybtcl runs on Unix, Windows NT and 95, and Macintosh platforms.
  668.  
  669. -------------------------------------------------------------------------------
  670.  
  671.                         The enabling language platform                         
  672.                                                                                
  673. Tool Command Language, often abbreviated "Tcl" and pronounced as "tickle", was
  674. created by Dr. John Ousterhout at the University of California-Berkeley. Tcl is
  675. an interpreted script language, similar to Unix shell, Awk, Perl, and others.
  676. Tcl was designed to be easily extended, where new commands are added to the
  677. base interpreter to provide additional functionality. Core Tcl commands contain
  678. all of the usual constructs provided by most programming languages: setting and
  679. accessing variables, file read/write, if-then-else, do-while, function calls.
  680. Tcl also contains many productivity enhancing commands: list manipulation,
  681. associative arrays, and regular expression processing.
  682.  
  683. Tcl has several features that make it a highly productive language. First, the
  684. language is interpreted. Interpreters allow execution without a compile and
  685. link step. Code can be developed with immediate feedback. Second, Tcl has a
  686. single data type: string. While this might at first glance seem to a
  687. deficiency, it avoids problems of data conversion and memory management. (This
  688. feature doesn't preclude Tcl from performing arithmetic operations.) Last, Tcl
  689. has a consistent and simple syntax, much the same as the Unix shell. Every Tcl
  690. statement is a command name, followed by arguments.
  691.  
  692. Dr. Ousterhout also developed a companion Tcl extension, called Tk. Tk provides
  693. simplified programming of X11 applications with a Motif look and feel. X11
  694. applications can be programmed with 60%-80% less code than equivalent Xt,
  695. Motif, or Xview programs using C or C++.
  696.  
  697. Dr. Ousterhout now leads Tcl/Tk development at Sun Microsystems.
  698.  
  699. -------------------------------------------------------------------------------
  700.  
  701.                               Design and commands                              
  702.                                                                                
  703. Sybtcl was designed to fill the gap between pure applications development tools
  704. (e.g. Apt, Powerbuilder, et.al.) and database administration tools, often Unix
  705. shell scripts consisting of 'isql' and Awk pipelines. Sybtcl extends the Tcl
  706. language with specialized commands for Sybase access. Sybtcl consists of a set
  707. of C language functions that interface DB-Library calls to the Tcl language.
  708.  
  709. Instead of a simple one-to-one interface to DB-Library, Sybtcl provides a
  710. high-level Sybase programming interface of its own. The following example is a
  711. complete Sybtcl program that illustrates the simplified interface. It relies on
  712. the Tcl interpreter, "tclsh", that has been extended with Sybtcl.
  713.  
  714.   #!/usr/local/bin/tclsh
  715.   set hand [sybconnect "mysybid" "mysybpasswd"]
  716.   sybuse $hand pubs2
  717.   sybsql $hand "select au_lname, au_fname from authors order by au_lname"
  718.   sybnext $hand {
  719.     puts [format "%s, %s" @1 @2]
  720.   }
  721.   sybclose $hand
  722.   exit
  723.  
  724. In this example, a Sybase server connection is established ("sybconnect"), and
  725. the "pubs" sample database is accessed ("sybuse"). An SQL statement is sent to
  726. the server ("sybsql"), and all rows returned are fetched and printed
  727. ("sybnext"). Finally, the connection is closed ("sybclose").
  728.  
  729. The same program can be made to display its output in an X11 window, with a few
  730. changes. The Tcl/Tk windowing shell, "wish", also extended with Sybtcl is used.
  731.  
  732.   #!/usr/local/bin/wish
  733.   listbox .sql_output
  734.   button  .exit -text exit -command exit
  735.   pack .sql_output .exit
  736.   set hand [sybconnect "mysybid" "mysybpasswd"]
  737.   sybuse $hand pubs2
  738.   sybsql $hand "select au_lname, au_fname from authors order by au_lname"
  739.   sybnext $hand {
  740.     .sql_output insert end  [format "%s, %s" @1 @2]
  741.   }
  742.   sybclose $hand
  743.  
  744. In addition to these commands, Sybtcl includes commands to access return column
  745. names and datatypes ("sybcols"), return values from stored procedures
  746. ("sybretval"), reading and writing of "text" or "image" columns ("sybreadtext",
  747. "sybwritetext"), canceling pending results ("sybcancel"), and polling
  748. asynchronous SQL execution ("sybpoll").
  749.  
  750. Full access to Sybase server messages is also provided. Sybtcl maintains a Tcl
  751. array variable which contains server messages, output from stored procedures
  752. ("print"), DB-Library and OS error message.
  753.  
  754. -------------------------------------------------------------------------------
  755.  
  756.                                  Applications                                  
  757.                                                                                
  758. The Sybtcl distribution includes "Wisqlite", an X11 SQL command processor.
  759. Wisqlite provides a typical windowing style environment to enter and edit SQL
  760. statements, list results of the SQL execution in a scrollable listbox, save or
  761. print output. In addition, menu access to the Sybase data dictionary is
  762. provided, listing tables in a database, the column names and datatypes of a
  763. table, text of stored procedures and triggers.
  764.  
  765. For a snapshot of Wisqlite in action, look here.
  766.  
  767. Other applications included in the Sybtcl distribution include:
  768.  
  769.   * a simple graphical performance monitor
  770.   * a version of "sp_who", with periodic refresh
  771.  
  772. Sybtcl users have reported a wide variety of applications written in Sybtcl,
  773. ranging from end user applications to database administration utilities.
  774.  
  775. -------------------------------------------------------------------------------
  776.  
  777.                               Information Sources                              
  778.                                                                                
  779. Sybtcl is extensively documented in "Tcl/Tk Tools", edited by Mark Harrison,
  780. published by O'Reilly and Associates, 1997, ISBN: 1-56592-218-2.
  781.  
  782. Tcl/Tk is described in detail in "Tcl and the Tk Toolkit" by Dr. John
  783. Ousterhout, Addison-Wesley Publishing 1994 ISBN: 0-201-63337-X . Another recent
  784. publication is "Practical Programming in Tcl and Tk" by Brent Welch, Prentice
  785. Hall 1995 ISBN 0-13-182007-9.
  786.  
  787. A wealth of information on Tcl/Tk is available via Internet sources:
  788.  
  789.     news:comp.lang.tcl
  790.     http://www.neosoft.com/tcl/
  791.     http://www.sco.com/Technology/tcl/Tcl.html
  792.     ftp://ftp.neosoft.com/pub/tcl/
  793.    
  794. -------------------------------------------------------------------------------
  795.  
  796.                                    Download                                    
  797.                                                                                
  798. Download Sybtcl in tar.gz format for Unix.
  799. Download Sybtcl in zip format for Windows NT and 95.
  800.  
  801. Tcl/Tk and Sybtcl are both released in source code form under a "BSD" style
  802. license. Tcl/Tk and Sybtcl may be freely used for any purpose, as long as
  803. copyright credit is given to the respective owners. Tcl/Tk can be obtained from
  804. either anonymous FTP site listed above.
  805.  
  806. Tcl/Tk and Sybtcl can be easily configured under most modern Unix systems
  807. including SunOS, Solaris, HP-UX, Irix, OSF/1, AIX, SCO, et.al. Sybtcl also runs
  808. under Windows NT and 95; pre-compiled DLL's are include in the distribution.
  809. Sybtcl requires Sybase's DB-Library, from Sybase's Open Client bundle.
  810.  
  811. Current versions are:
  812.  
  813.   * Sybtcl 2.5: released January 8, 1998
  814.   * Tcl 8.0: released August 13, 1997
  815.   * Tk 8.0: released August 13, 1997
  816.  
  817. The Internet newsgroup comp.lang.tcl is the focal point for support. The group
  818. is regularly read by developers and users alike. Authors may also be reached
  819. via email. Sun has committed to keeping Tcl/Tk as freely available software.
  820.  
  821. -------------------------------------------------------------------------------
  822.  
  823.                                About the Author                                
  824.                                                                                
  825. Tom Poindexter is a consultant with expertise in Unix, relational databases,
  826. systems and application programming. He holds a B.S. degree from the University
  827. of Missouri, and an M.B.A. degree from Illinois State University. He can be
  828. reached at tpoindex@nyx.net.
  829.  
  830. Back to top
  831.  
  832. -------------------------------------------------------------------------------
  833.  
  834. 9.4.2: sybdump
  835.  
  836. -------------------------------------------------------------------------------
  837.  
  838. Sybdump is a Tcl script written by De Clarke (de@ucolick.org) for extracting a
  839. database schema.  Look in
  840.  
  841. ftp://ftp.ucolick.org/pub/src/UCODB
  842.  
  843. for sybdump.tar or sybdump.tar.gz.
  844.  
  845. Back to top
  846.  
  847. -------------------------------------------------------------------------------
  848.  
  849. 9.4.3: wisql
  850.  
  851. -------------------------------------------------------------------------------
  852.  
  853. Another Sybtcl package maintained by De Clarke (de@ucolick.org) this one is a
  854. graphical replacement for isql. Correct me if I am wrong, but I think that this
  855. started life as wisqlite and was included as part of the Sybtcl package and was
  856. then updated by De and became wisql.
  857.  
  858. You can grab a copy of wisql from ftp://ftp.ucolick.org:/pub/UCODB/
  859. wisql5B.tar.gz
  860.  
  861. Back to top
  862.  
  863. -------------------------------------------------------------------------------
  864.  
  865. 9.5.1: Sybase Module for Python
  866.  
  867. -------------------------------------------------------------------------------
  868.  
  869. Dave Cole has a module for Python that allows connectivity to Sybase in an
  870. analagous way to Sybperl or Sybtcl. You can find details from http://
  871. www.object-craft.com.au/projects/sybase/.
  872.  
  873. Back to top
  874.  
  875. -------------------------------------------------------------------------------
  876.  
  877. 9.6.1: SQSH, SQshelL
  878.  
  879. SQSH is a direct replacement for isql with a million more bells and whistles.
  880. In fact, the title gives it away, since SQSH is a pretty seemless marriage of
  881. sh(1)
  882. and isql.
  883.  
  884. There has been a webified copy of the SQSH FAQ based on the 1.4 release
  885. contained within these pages for a while, but it is considerably behind the
  886. times. As such, I have moved the 1.4 release to a separate file readable from 
  887. here.
  888.  
  889. The current SQSH FAQ can be seen on Scott's own site, http://www.voicenet.com/
  890. ~gray/FAQ.html.
  891.  
  892. -------------------------------------------------------------------------------
  893.  
  894. Back to top
  895.  
  896. -------------------------------------------------------------------------------
  897.  
  898. 9.6.2: NTQuery.exe
  899.  
  900. -------------------------------------------------------------------------------
  901.  
  902. Brief
  903.  
  904. ntquery.exe is a 32-bit application allowing a lightweight, but robust sybase
  905. access environment for win95/NT. It has a split window - the top for queries,
  906. the bottom for results and error/message handler responses, which are processed
  907. in-line. Think of it as isql for windows - a better (reliable) version of wisql
  908. (with sensible error handling). Because its simple it can be used against
  909. rep-server (I've also used it against Navigation Server(R.I.P.))
  910.  
  911. Requirements: open client/dblib (Tested with 10.x up to 11.1.1)
  912.  
  913. It picks up the server list from %SYBASE%\ini\sql.ini and you can add
  914. DSQUERY,SYBUSER and SYBPASS variables in your user variables to set default
  915. server,username and password values.
  916.  
  917. Instructions
  918.  
  919. To connect: SQL->CONNECT (only one connection at a time, but you can run
  920. multiple ntquery copies) Enter query in top window and hit F3 (or SQL->Execute
  921. Query if you must use the mouse) Results/Messages/Errors appear in bottom
  922. window
  923.  
  924. A script can be loaded into the top window via File->Open Either sql or results
  925. can be saved with File->Save - it depends which window your focus is on.
  926.  
  927. Theres a buffer limit of 2mb
  928.  
  929. Get it here
  930.  
  931. ntquery.zip [22K]
  932.  
  933. Back to top
  934.  
  935. -------------------------------------------------------------------------------
  936.  
  937. 9.6.3: BCPTool - A utility for Transferring Data from one ASE to Another.
  938.  
  939. -------------------------------------------------------------------------------
  940.  
  941. BCPTool is a GUI utility written by Anthony Mandic that moves data from one ASE
  942. to another. It runs on Solaris and Linux and is very straightforward to use.
  943.  
  944. Go to http://www.mbay.net/~mpeppler/bcptool to grab a copy, read the
  945. documentation and see a couple of screen shots.
  946.  
  947. Hot news! Michael Peppler is porting BCPtool to use the GTK+ libraries, which
  948. is basically the standard gnome toolkit for Linux. Go to Michael's site for
  949. more details (http://www.mbay.net/~mpeppler).
  950.  
  951. Back to top
  952.  
  953. -------------------------------------------------------------------------------
  954.  
  955. 9.7.1: How to access a SQL Server using Linux
  956.  
  957. -------------------------------------------------------------------------------
  958.  
  959. I am planning to remove/reduce/rewrite this section when the ASE on Linux FAQ
  960. moves to section 2. Most of it is out of date, and I think that most of its
  961. links are broken.
  962.  
  963. Some time back, Sybase released a binary distribution of ctlib for Linux. This
  964. is just the header and libraries files for ctlib only, not dblib, not isql, not
  965. bcp, not the dataserver and not the OpenServer. This was done as a skunk works
  966. internal project at Sybase, for the good of the Linux community, and not
  967. supported by Sybase in any official capacity. This version of ctlib identifies
  968. itself as 10.0.3.
  969.  
  970. At the time, the binary format for Linux libraries was a format called a.out.
  971. Since then, the format has changed to the newer, ELF format. ELF libraries and
  972. .o files cannot be linked with a.out libraries and .o files. Fortunately, a.out
  973. libraries and .o files can easily be converted to ELF via the objdump(1)
  974. program.
  975.  
  976. Getting a useable ctlib for Linux isn't that easy, though. Another
  977. compatibility problem has arisen since these old libraries were compiled. The
  978. byte-order for the ctype macros has changed. One can link to the
  979. (converted-to-ELF) ctlib, but running the resulting executable will result in
  980. an error message having to do with missing localization files. The problem is
  981. that the ctype macros in the compiled ctlib libraries are accessing a structure
  982. in the shared C library which has changed its byte order.
  983.  
  984. I've converted the a.out library, as distributed by Sybase to ELF, and added
  985. the old tables directly to the library, so that it won't find the wrong ones in
  986. libc.
  987.  
  988. Using this library, I can link and run programs on my Linux machines against
  989. Sybase databases (It also can run some programs against Microsoft SQL server,
  990. but that's another FAQ). However, you must be running Linux 2.0 or later, or
  991. else the link phase will core dump.
  992.  
  993. This library is available for ftp at:
  994.  
  995.   * ftp://mudshark.sunquest.com/pub/ctlib-linux-elf/sybperl.tar.gz
  996.   * ftp://mudshark.sunquest.com/pub/ctlib-linux-elf/ctlib-linux-elf.tgz
  997.  
  998. is a compiled version of sybperl 2.0, which is built with the above library.
  999. Obviously, only the ctlib module is in this distribution.
  1000.  
  1001. In order to use this code, you will need a Sybase dataserver, a Sybase
  1002. interfaces file (in the non-TLI format -- see Q9.3.4), a user named sybase in
  1003. your /etc/passwd file, whose home directory is the root of the distribution,
  1004. and some application code to link to.
  1005.  
  1006. As far as an isql replacement goes, use sqsh - Q9.5.1.
  1007.  
  1008. One of the libraries in the usual Sybase distribution is a libtcl.a This
  1009. conflicts with the library on Linux which implements the TCL scripting
  1010. language, so this distribution names that library libsybtcl.a, which might
  1011. cause some porting confusion.
  1012.  
  1013.     The above conflict problem is addressed by SybPerl - Q9.3.1 and sqsh -
  1014.     Q9.5.1
  1015.    
  1016. More information
  1017.  
  1018. See Q11.4.6 for more information on setting up DBI/DBD:Sybase
  1019.  
  1020. Back to top
  1021.  
  1022. -------------------------------------------------------------------------------
  1023.  
  1024. 9.7.2: Sybase on Linux FAQ
  1025.  
  1026. -------------------------------------------------------------------------------
  1027.  
  1028. I am planning to move this section out of here next release.
  1029.  
  1030. Sybase have released two versions of Sybase on Linux, 11.0.3.3 and 11.9.2, and
  1031. a third, 12.5, is in beta testing at this moment, slated for GA sometime in the
  1032. first half of 2001.
  1033.  
  1034. 11.9.2
  1035.  
  1036. This is officially supported and sanctioned.  The supported version can be
  1037. purchased from Sybase at similar, if not exactly the same, conditions as 11.9.2
  1038. on NT, with one small exception: you can download a developer's version for
  1039. free!  There is a 11.9.2.2 EBF, although I am not 100% sure if the current
  1040. developer's release is 11.9.2 or 11.9.2.2. Certainly for a while, you could
  1041. only get the EBF if you had a paid for version.
  1042.  
  1043. 11.0.3.3
  1044.  
  1045.     Please remember that Sybase Inc does not provide any official support for
  1046.     SQL Server on Linux (ie the 11.0.3.3 release). The folks on the 'net
  1047.     provide the support.
  1048.    
  1049. Index
  1050.  
  1051.   * Minimum Requirements
  1052.   * How to report a bug
  1053.   * Bug list
  1054.  
  1055. Minimum Requirements
  1056.  
  1057.   * Linux release: 2.0.36 or 2.1.122 or greater.
  1058.  
  1059. How to report a bug
  1060.  
  1061. I hope you understand that the Sybase employee who did the port is a very busy
  1062. person so it's best not to send him mail regarding trivial issues. If you have
  1063. tried posting to comp.databases.sybase and ase-linux-list@isug.com and have
  1064. checked the bugs list, send him an e-mail note with the following data - you
  1065. will not get an acknowledgement to your e-mail and it will go directly into the
  1066. bug tracking database; true bugs will be fixed in the next release; any message
  1067. without the above Subject will be deleted, unseen, by a filter.
  1068.  
  1069.     Administrator: I know that the above sounds harsh but Wim ten has been
  1070.     launched to world-wide exposure. In order for him to continue to provide
  1071.     Sybase ASE outside of his normal workload we all have to support him.
  1072.     Thanks!
  1073.    
  1074. With the above out of the way, if you find a bug or an issue please report it
  1075. as follows:
  1076.  
  1077.     To: wtenhave@sybase.com
  1078.     Subject: SYBASE ASE LINUX PR
  1079.     uname: the result of typing 'uname -a' in a shell
  1080.     $SYBASE/scripts/hw_info.sh: As 'sybase' run this shell script and enclose
  1081.     its output
  1082.     short description: a one to two line description of the problem
  1083.     repeatable: yes, you can repeat it, no you cannot
  1084.     version of dataserver: the result of: as the 'sybase' user, 'cd $SYBASE/bin
  1085.     ' and type './dataserver -v|head -1'
  1086.     test case: test case to reproduce the problem
  1087.    
  1088.                                    Bug List                                    
  1089. +-----------------------------------------------------------------------------+
  1090. |             |        |              |             |             |           |
  1091. |-------------+--------+--------------+-------------+-------------+-----------|
  1092. |    Short    | Fixed? |  Dataserver  |    Date     |  Fix Date   | Fix Notes |
  1093. | Description |        |   Release    |  Reported   |             |           |
  1094. |-------------+--------+--------------+-------------+-------------+-----------|
  1095. |             |        | SQL Server/  |             |             | You must  |
  1096. |             |        | 11.0.3.3/P/  |             |             | upgrade   |
  1097. | Remote      |        | Linux Intel/ | Pre-release | Pre-release | your OS   |
  1098. | connections | Yes    | Linux 2.0.36 | of SQL      | of SQL      | to either |
  1099. | hang        |        | i586/1/OPT/  | Server      | Server      | 2.0.36 or |
  1100. |             |        | Thu Sep 10   |             |             | 2.1.122   |
  1101. |             |        | 13:42:44     |             |             | or        |
  1102. |             |        | CEST 1998    |             |             | greater   |
  1103. +-----------------------------------------------------------------------------+
  1104.  
  1105. as of Fri Nov 20 20:16 (08:16:47 PM) MST 1998
  1106.  
  1107. Back to top
  1108.  
  1109. -------------------------------------------------------------------------------
  1110.  
  1111. 9.7.3: Linux Shared Memory for ASE (x86 Processors)
  1112.  
  1113. -------------------------------------------------------------------------------
  1114.  
  1115. 2.2.x Series Kernels and Above
  1116.  
  1117. To set the maximum shared memory to 128M use the following:
  1118.  
  1119. # echo 134217728 > /proc/sys/kernel/shmmax
  1120.  
  1121. This comes from the following calculation: 128Mb = 128 x 1024 x 1024 bytes =
  1122. 134217728 bytes
  1123.  
  1124. 2.0.x and 2.1.x Kernels
  1125.  
  1126. To increase the total memory for ASE (SQL Server) beyond 32mb, several kernel
  1127. parameters must be changed.
  1128.  
  1129.  1. Determine Memory/System Requirements
  1130.       + a: Total Memory < 128mb specific instructions
  1131.       + b: Total Memory > 128MB - specific instructions
  1132.  2. Modify the linux/include/asm/shmparam.h to setup shared memory
  1133.  3. Increase the size of the swap
  1134.  4. Recompile your kernel & start using the new kernel
  1135.  5. Verify the changes have taken effect
  1136.  6. Increase the total memory to the desired size
  1137.  
  1138. Comments
  1139.  
  1140. -------------------------------------------------------------------------------
  1141.  
  1142. 1a - Total Memory < 128mb specific instructions
  1143.  
  1144. -------------------------------------------------------------------------------
  1145.  
  1146. Requirements:
  1147.  
  1148. Linux 2.0.36 or higher
  1149.  
  1150. Total memory is currently limited to 128mb. A request to the Linux kernel
  1151. developers has been made to enable large swap support which will allow the same
  1152. size as 2.2.x kernels.
  1153.  
  1154. -------------------------------------------------------------------------------
  1155.  
  1156. 1b - Total Memory > 128mb - specific instructions
  1157.  
  1158. -------------------------------------------------------------------------------
  1159.  
  1160. Requirements:
  1161.  
  1162.   * Linux Kernel 2.2.x or higher *
  1163.   * util-linux package 2.9 or higher *
  1164.   * Swap space atleast as large as the SQL Server
  1165.  
  1166.  
  1167. * - both are available from ftp://ftp.us.kernel.org
  1168.  
  1169. You need to make the following changes in linux/include/asm-i386/page.h:
  1170.  
  1171. - #define __PAGE_OFFSET (0xC0000000)
  1172. + #define __PAGE_OFFSET (0x80000000)
  1173.  
  1174. This allows accessing up to 2gb of memory. Default is 960mb.
  1175.  
  1176. -------------------------------------------------------------------------------
  1177.  
  1178. Step 2: Modify the linux/include/asm/shmparam.h to setup shared memory
  1179.  
  1180. -------------------------------------------------------------------------------
  1181.  
  1182.    
  1183.     [max seg size]
  1184.     - #define SHMMAX 0x2000000 /* defaults to 32 MByte */
  1185.     + #define SHMMAX 0x7FFFE000 /* 2048mb - 8k */
  1186.    
  1187.     [max number of segments]
  1188.     - #define _SHM_ID_BITS 7 /* maximum of 128 segments */
  1189.     + #define _SHM_ID_BITS 5 /* maximum of 32 segments */
  1190.    
  1191.     [number of bits to count how many pages in the shm segment]
  1192.     - #define _SHM_IDX_BITS 15 /* maximum 32768 pages/segment */
  1193.     + #define _SHM_IDX_BITS 19 /* maximum 524288 pages/segment */
  1194.    
  1195.     Alter _SHM_IDX_BITS only if you like to go beyond the default 128MByte
  1196.     where you also need the swap space available.
  1197.    
  1198.     _SHM_ID_BITS + _SHM_IDX_BITS must be equal to or less then 24.
  1199.    
  1200.     Linux kernel PAGE size for Intel x86 machines = 4k
  1201.    
  1202. -------------------------------------------------------------------------------
  1203.  
  1204. Step 3: To increase the size of swap
  1205.  
  1206. -------------------------------------------------------------------------------
  1207.  
  1208.        
  1209.         $ mkswap -c <device> [size] <- use for pre 2.2 kernels
  1210.         - limited to 128mb - 8k
  1211.        
  1212.         $ mkswap -c -v1 <device> [size] <- limited to 2gb 8k
  1213.        
  1214.         $ swapon <device>
  1215.        
  1216.   * Add the following to your /etc/fstab to enable this swap on boot
  1217.        
  1218.         <device> swap swap defaults 0 0
  1219.        
  1220. -------------------------------------------------------------------------------
  1221.  
  1222. Step 4: Recompile your kernel & restart using the new kernel
  1223.  
  1224. -------------------------------------------------------------------------------
  1225.  
  1226.    
  1227.     Follow the instructions provided with the Linux Kernel
  1228.    
  1229. -------------------------------------------------------------------------------
  1230.  
  1231. Step 5: Verify the changes have taken effect
  1232.  
  1233. -------------------------------------------------------------------------------
  1234.  
  1235.    
  1236.     $ ipcs -lm
  1237.    
  1238.     ------ Shared Memory Limits --------
  1239.     max number of segments = 32
  1240.     max seg size (kbytes) = 2097144
  1241.     max total shared memory (kbytes) = 67108864
  1242.     min seg size (bytes) = 1
  1243.    
  1244.     [jfroebe@jfroebe-desktop asm]$
  1245.    
  1246.     The changes took.
  1247.    
  1248. -------------------------------------------------------------------------------
  1249.  
  1250. Step 6: Increase the total memory to the desired size
  1251.  
  1252. -------------------------------------------------------------------------------
  1253.  
  1254.    
  1255.     Because of current limitations in the GNU C Library (glibc), ASE is limited
  1256.     to 893mb. A workaround to increase this to 1400mb has been submitted.
  1257.    
  1258.     Increase the total memory to desired size. Remember the above limitation as
  1259.     well as the 128mb limitation on Linux kernel 2.0.36.
  1260.    
  1261.     For example, to increase the total memory to 500mb:
  1262.        
  1263.         1> sp_configure "total memory", 256000
  1264.         2> go
  1265.         1> shutdown
  1266.         2> go
  1267.        
  1268. -------------------------------------------------------------------------------
  1269.  
  1270. Comments
  1271.  
  1272. * Note that it is possible to increase the total memory far above the physical
  1273. RAM
  1274.  
  1275. Back to top
  1276.  
  1277. -------------------------------------------------------------------------------
  1278.  
  1279. 9.7.4: Sybase now available on Free BSD
  1280.  
  1281. -------------------------------------------------------------------------------
  1282.  
  1283. Amazing, the Sybase folks have got ASE running on FreeBSD!  The following post
  1284. is from Reinoud van Leeuwen (reinoud.v@n.leeuwen.net). His web site is http://
  1285. www.xs4all.nl/~reinoud and contains lots of other useful stuff.
  1286.  
  1287. Sybase has made an update of their free 11.0.3.3 SQL server available.  This
  1288. updated version includes some bug fixes and *FreeBSD support*.
  1289.  
  1290. The 11.0.3.3 version is unsupported, but Free for development *and production*!
  1291.  
  1292. The server still runs under the Linux emulation, but there is a native SDK
  1293. (libraries).
  1294.  
  1295. download on
  1296.  
  1297. http://www.sybase.com/linux/ase/
  1298.  
  1299. some extra info on:
  1300.  
  1301. http://my.sybase.com/detail?id=1009270
  1302.  
  1303. Here are the notes I made to get everything working (still working on things
  1304. like sybperl, dbd::sybase and PHP :-)
  1305.  
  1306. notes on getting Sybase to work on FreeBSD 4.0 RELEASE
  1307. ======================================================
  1308.  
  1309. (log in as root)
  1310.  
  1311. 1: create a user sybase. give it /usr/local/sybase as home  directory. I gave
  1312. him bash as shell and put him in the group sybase 
  1313.  
  1314. 2: put the following files in /usr/local (they contain the path sybase): 
  1315.  
  1316.   * sybase-ase-11.0.3.3-FreeBSD-6.i386.tgz 
  1317.   * sybase-doc-11.0.3.3-FreeBSD-6.i386.tgz 
  1318.   * sybase-ocsd-10.0.4-FreeBSD-6.i386.tgz 
  1319.  
  1320. 3: untar them: 
  1321.  
  1322.  tar xvzf sybase-ase-11.0.3.3-FreeBSD-6.i386.tgz
  1323.  tar xvzf sybase-doc-11.0.3.3-FreeBSD-6.i386.tgz
  1324.  tar xvzf sybase-ocsd-10.0.4-FreeBSD-6.i386.tgz
  1325.  rm sybase*.tgz
  1326.  
  1327. 4: change the ownership of the tree to sybase:
  1328.  
  1329.  chown -R sybase:sybase /usr/local/sybase
  1330.  
  1331. 5: install the FreeBSD linux emulation:
  1332.  
  1333.   * add the following line to /etc/rc.conf
  1334.     linux_enable="YES"
  1335.   * build the following ports:
  1336.     /usr/ports/emulators/linux_base
  1337.  
  1338. (TIP: move the nluug site up in the makefile, this speeds up things
  1339. considerably from the Netherlands!)
  1340.  
  1341. 6: build a kernel that supports System V shared memory blocks make sure that
  1342. the following lines are in the kernel config file (/sys/i386/conf/YOUR_KERNEL)
  1343.  
  1344. # the next 3 are now standard in the kernel
  1345.  options SYSVSHM
  1346.  options SYSVMSG
  1347.  options SYSVSEM
  1348.  
  1349.  options SHMMAXPGS="8192"
  1350.  options SHMMAX="(SHMMAXPGS*PAGE_SIZE+1)"
  1351.  
  1352. (this might be a good time to also enable your kernel for Multi processor) It
  1353. is also possible to set the last two entries during runtime:
  1354.  
  1355. sysctl -w kern.ipc.shmmax=32000000
  1356. sysctl -w kern.ipc.shmall=8192
  1357.  
  1358. (log in as sybase or su to it; make sure that the SYBASE environment variable
  1359. is set to /usr/local/sybase ; the .cshrc file should set it.)
  1360.  
  1361. 7: brand some executables to make sure FreeBSD knows that they are Linux ones 
  1362.  
  1363.  brandelf -t Linux /usr/local/sybase/install/sybinit
  1364.  brandelf -t Linux /usr/local/sybase/install/startserver
  1365.  brandelf -t Linux /usr/local/sybase/bin/*
  1366.  
  1367. 8: run ./install/sybinit
  1368.  
  1369. With this program you should be able to install a sybase server and a backup
  1370. server. (see the included docs or the online manuals on http://
  1371. sybooks.sybase.com)
  1372.  
  1373. 9: To make Sybase start during system boot copy the following script to /usr/
  1374. local/etc/rc.d and make it executable by root
  1375.  
  1376.  #!/bin/sh
  1377.  # start all sybase servers on this system
  1378.  # assume that sybase is installed in the home dir of user
  1379.  # sybase
  1380.  export SYBASE=`grep -e "^sybase" /etc/passwd | cut -d: -f 6`
  1381.  export PATH="${SYBASE}/bin:${SYBASE}/install:${PATH}"
  1382.  
  1383.  unset LANG
  1384.  unset LC_ALL
  1385.  
  1386.  cd ${SYBASE}/install
  1387.  
  1388.  for RUN_SERVER in RUN_*
  1389.  do
  1390.       su sybase -c "startserver -f ${RUN_SERVER}" > /dev/null 2>&1
  1391.       echo -n "${RUN_SERVER} "
  1392.  done
  1393.  echo
  1394.  
  1395. # end of script
  1396.  
  1397. Getting 2 CPU's working
  1398. =======================
  1399.  
  1400. Two get Sybase running on 2 CPU's involves two steps:
  1401.  
  1402.   * getting Unix working on 2 CPU's and
  1403.   * configuring Sybase to use them.
  1404.  
  1405. 1: Getting FreeBSD to work on 2 CPU's.
  1406.  
  1407. Build a new kernel that supports 2 CPU's. Run the command mptable (as root).
  1408. note the last few lines of output, they will tell you what you should include
  1409. in your kernel file.
  1410.  
  1411. Edit the Kernel file and build it. Note the messages during the next reboot. It
  1412. should say somewhere that it uses the second CPU now.
  1413.  
  1414. 2: insert the following line in the sybase.sh startup script in /usr/local/etc/
  1415. rc.d
  1416.  
  1417.  export SRV_CPUCOUNT=2 
  1418.  
  1419. Also insert this line in the files where environment variables are set for the
  1420. user sybase. Edit the config file for the sybase server(s) on your system (/usr
  1421. /local/sybase/<SERVERNAME>.cfg). Change the values in the line "max online
  1422. engines" from "Default" to "2". (Another option is to give the SQL command
  1423. sp_configure "max online engines",2) During the next Sybase reboot, the last
  1424. line in the errorlog should say something like:
  1425.  
  1426. engine 1, os pid xxx online
  1427.  
  1428. there should be two processes with the name dataserver now.
  1429.  
  1430.  
  1431. Back to top
  1432. -------------------------------------------------------------------------------
  1433.  
  1434. 9.8.1: Other Extended Stored Procedures
  1435.  
  1436. -------------------------------------------------------------------------------
  1437.  
  1438. The following stored procedures were written by Ed Barlow sqltech@tiac.net and
  1439. can be fetched from the following site:
  1440.  
  1441.     http://www.edbarlow.com
  1442.    
  1443. Here's a pseudo-man page of what you get:
  1444.  
  1445.                   Modified Sybase Procedures                   
  1446.         +-------------------------------------------------------------+        
  1447.         |               |                                             |        
  1448.         |---------------+---------------------------------------------|        
  1449.         |    Command    |                 Description                 |        
  1450.         |---------------+---------------------------------------------|        
  1451.         |---------------+---------------------------------------------|        
  1452.         |sp__help       |Better sp_help                               |        
  1453.         |---------------+---------------------------------------------|        
  1454.         |sp__helpdb     |Database Information                         |        
  1455.         |---------------+---------------------------------------------|        
  1456.         |sp__helpdevice |Break down database devices into a nice      |        
  1457.         |               |report                                       |        
  1458.         |---------------+---------------------------------------------|        
  1459.         |sp__helpgroup  |List groups in database by access level      |        
  1460.         |---------------+---------------------------------------------|        
  1461.         |sp__helpindex  |Shows indexes by table                       |        
  1462.         |---------------+---------------------------------------------|        
  1463.         |sp__helpsegment|Segment Information                          |        
  1464.         |---------------+---------------------------------------------|        
  1465.         |sp__helpuser   |Lists users in current database by group     |        
  1466.         |               |(include aliases)                            |        
  1467.         |---------------+---------------------------------------------|        
  1468.         |sp__lock       |Lock information                             |        
  1469.         |---------------+---------------------------------------------|        
  1470.         |sp__who        |sp_who that fits on a page                   |        
  1471.         +-------------------------------------------------------------+        
  1472.                        Audit Procedures                        
  1473.         +-------------------------------------------------------------+        
  1474.         |                 |                                           |        
  1475.         |-----------------+-------------------------------------------|        
  1476.         |     Command     |                Description                |        
  1477.         |-----------------+-------------------------------------------|        
  1478.         |sp__auditsecurity|Security Audit On Server                   |        
  1479.         |-----------------+-------------------------------------------|        
  1480.         |sp__auditdb      |Audit Current Database For Potential       |        
  1481.         |                 |Problems                                   |        
  1482.         +-------------------------------------------------------------+        
  1483.                 System Administrator Procedures                
  1484.         +-------------------------------------------------------------+        
  1485.         |              |                                              |        
  1486.         |--------------+----------------------------------------------|        
  1487.         |   Command    |                 Description                  |        
  1488.         |--------------+----------------------------------------------|        
  1489.         |--------------+----------------------------------------------|        
  1490.         |sp__block     |Blocking processes.                           |        
  1491.         |--------------+----------------------------------------------|        
  1492.         |sp__dbspace   |Summary of current database space information.|        
  1493.         |--------------+----------------------------------------------|        
  1494.         |sp__dumpdevice|Listing of Dump devices                       |        
  1495.         |--------------+----------------------------------------------|        
  1496.         |sp__helpdbdev |Show how Databases use Devices                |        
  1497.         |--------------+----------------------------------------------|        
  1498.         |sp__helplogin |Show logins and remote logins to server       |        
  1499.         |--------------+----------------------------------------------|        
  1500.         |sp__helpmirror|Shows mirror information, discover broken     |        
  1501.         |              |mirrors                                       |        
  1502.         |--------------+----------------------------------------------|        
  1503.         |sp__segment   |Segment Information                           |        
  1504.         |--------------+----------------------------------------------|        
  1505.         |sp__server    |Server summary report (very useful)           |        
  1506.         |--------------+----------------------------------------------|        
  1507.         |sp__vdevno    |Who's who in the device world                 |        
  1508.         +-------------------------------------------------------------+        
  1509.                         DBA Procedures                         
  1510.         +-------------------------------------------------------------+        
  1511.         |               |                                             |        
  1512.         |---------------+---------------------------------------------|        
  1513.         |    Command    |                 Description                 |        
  1514.         |---------------+---------------------------------------------|        
  1515.         |---------------+---------------------------------------------|        
  1516.         |sp__badindex   |give information about bad indexes (nulls,   |        
  1517.         |               |bad statistics...)                           |        
  1518.         |---------------+---------------------------------------------|        
  1519.         |sp__collist    |list all columns in database                 |        
  1520.         |---------------+---------------------------------------------|        
  1521.         |sp__indexspace |Space used by indexes in database            |        
  1522.         |---------------+---------------------------------------------|        
  1523.         |sp__noindex    |list of tables without indexes.              |        
  1524.         |---------------+---------------------------------------------|        
  1525.         |sp__helpcolumns|show columns for given table                 |        
  1526.         |---------------+---------------------------------------------|        
  1527.         |sp__helpdefault|list defaults (part of objectlist)           |        
  1528.         |---------------+---------------------------------------------|        
  1529.         |sp__helpobject |list objects                                 |        
  1530.         |---------------+---------------------------------------------|        
  1531.         |sp__helpproc   |list procs (part of objectlist)              |        
  1532.         |---------------+---------------------------------------------|        
  1533.         |sp__helprule   |list rules (part of objectlist)              |        
  1534.         |---------------+---------------------------------------------|        
  1535.         |sp__helptable  |list tables (part of objectlist)             |        
  1536.         |---------------+---------------------------------------------|        
  1537.         |sp__helptrigger|list triggers (part of objectlist)           |        
  1538.         |---------------+---------------------------------------------|        
  1539.         |sp__helpview   |list views (part of objectlist)              |        
  1540.         |---------------+---------------------------------------------|        
  1541.         |sp__trigger    |Useful synopsis report of current database   |        
  1542.         |               |trigger schema                               |        
  1543.         +-------------------------------------------------------------+        
  1544.                       Reverse Engineering                      
  1545.         +-------------------------------------------------------------+        
  1546.         |                 |                                           |        
  1547.         |-----------------+-------------------------------------------|        
  1548.         |     Command     |                Description                |        
  1549.         |-----------------+-------------------------------------------|        
  1550.         |-----------------+-------------------------------------------|        
  1551.         |sp__revalias     |get alias script for current db            |        
  1552.         |-----------------+-------------------------------------------|        
  1553.         |sp__revdb        |get db creation script for server          |        
  1554.         |-----------------+-------------------------------------------|        
  1555.         |sp__revdevice    |get device creation script                 |        
  1556.         |-----------------+-------------------------------------------|        
  1557.         |sp__revgroup     |get group script for current db            |        
  1558.         |-----------------+-------------------------------------------|        
  1559.         |sp__revindex     |get indexes script for current db          |        
  1560.         |-----------------+-------------------------------------------|        
  1561.         |sp__revlogin     |get logins script for server               |        
  1562.         |-----------------+-------------------------------------------|        
  1563.         |sp__revmirror    |get mirroring script for server            |        
  1564.         |-----------------+-------------------------------------------|        
  1565.         |sp__revuser      |get user script for current db             |        
  1566.         +-------------------------------------------------------------+        
  1567.                        Other Procedures                        
  1568.         +-------------------------------------------------------------+        
  1569.         |               |                                             |        
  1570.         |---------------+---------------------------------------------|        
  1571.         |    Command    |                 Description                 |        
  1572.         |---------------+---------------------------------------------|        
  1573.         |---------------+---------------------------------------------|        
  1574.         |sp__bcp        |Create unix script to bcp in/out database    |        
  1575.         |---------------+---------------------------------------------|        
  1576.         |sp__date       |Who can remember all the date styles?        |        
  1577.         |---------------+---------------------------------------------|        
  1578.         |sp__quickstats |Quick dump of server summary information     |        
  1579.         +-------------------------------------------------------------+        
  1580.  
  1581. Back to top
  1582.  
  1583. -------------------------------------------------------------------------------
  1584.  
  1585. 9.8.3: xsybmon
  1586.  
  1587. -------------------------------------------------------------------------------
  1588.  
  1589. The original site, NSCU, no longer carries these bits. If you feel that it's
  1590. useful to have xsybmon and you know where the new bits are, please drop me an
  1591. e-mail: dowen@midsomer.org
  1592.  
  1593. There is an alternative that is include as part of De Clarke's wisql package.
  1594. It is called syperf. I do not have any screen shots, but I will work on it. You
  1595. can grab a copy of wisql from ftp://ftp.ucolick.org:/pub/UCODB/wisql5B.tar.gz
  1596.  
  1597. Back to top
  1598.  
  1599. -------------------------------------------------------------------------------
  1600.  
  1601. Sybase Tech Docs Open Client ASE FAQ
  1602.  
  1603.