r9756: add tinyint type
[clsql.git] / doc / ref-ooddl.xml
1 <?xml version='1.0' ?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4 <!ENTITY % myents SYSTEM "entities.inc">
5 %myents;
6 ]>
7
8 <!-- Object Oriented Data Definition Language --> 
9 <reference id="ref-ooddl"> 
10   <title>Object Oriented Data Definition Language (OODDL)</title> 
11   <partintro>
12     <para>
13       The Object Oriented Data Definition Language (OODDL) provides
14       access to relational SQL tables using Common Lisp Object System
15       (CLOS) objects.  SQL tables are mapped to CLOS objects with the
16       SQL columns being mapped to slots of the CLOS object.
17     </para>
18     <para> 
19       The mapping between SQL tables and CLOS objects is defined
20       with the macro <link
21       linkend="def-view-class"><function>def-view-class</function></link>. SQL
22       tables are created with <link
23       linkend="create-view-from-class"><function>create-view-from-class</function></link>
24       and SQL tables can be deleted with <link
25       linkend="drop-view-from-class"><function>drop-view-from-class</function></link>.
26     </para>
27     <note>
28       <para>The above functions refer to the Lisp <emphasis>view</emphasis> of the SQL
29     table. This Lisp view should not be confused with SQL <function>VIEW</function> statement.</para>
30     </note>
31   </partintro>
32
33   <refentry id="standard-db-object">
34     <refnamediv>
35       <refname>STANDARD-DB-OBJECT</refname>
36       <refpurpose>Superclass for all &clsql; View Classes.</refpurpose>
37       <refclass>Class</refclass>
38     </refnamediv>
39     <refsect1>
40       <title>Class Precedence List</title>
41       <para>
42         <simplelist type="inline">
43           <member><type>standard-db-object</type></member>
44           <member><type>standard-object</type></member>
45           <member><type>t</type></member>
46         </simplelist>
47       </para>
48     </refsect1>
49     <refsect1>
50       <title>Description</title> <para>This class is the superclass
51       of all &clsql; View Classes.</para>
52     </refsect1>
53     <refsect1>
54       <title>Class details</title>
55       <programlisting>(defclass STANDARD-DB-OBJECT ()(...))</programlisting>
56     </refsect1>
57     <refsect1>
58       <title>Slots</title>
59       <para>
60         <simplelist> 
61           <member>slot VIEW-DATABASE is of type (OR NULL DATABASE)
62           which stores the associated database for the
63           instance.</member>
64         </simplelist> 
65       </para>
66     </refsect1>
67   </refentry>
68
69   <refentry id="default-string-length">
70     <refnamediv>
71       <refname>*DEFAULT-STRING-LENGTH*</refname>
72       <refpurpose>Default length of SQL strings.</refpurpose>
73       <refclass>Variable</refclass>
74     </refnamediv>
75     <refsect1>
76       <title>Value Type</title>
77       <para>
78         Fixnum
79       </para> 
80     </refsect1>
81     <refsect1>
82       <title>Initial Value</title>
83       <para><parameter>255</parameter></para>
84     </refsect1>
85     <refsect1>
86       <title>Description</title> 
87       <para>
88         If a slot of a class defined by
89         <function>DEF-VIEW-CLASS</function> is of the type
90         <parameter>STRING</parameter> or <parameter>VARCHAR</parameter> and does
91         not have a length specified, then the value of this variable
92         is used as SQL length.
93       </para>
94     </refsect1>
95     <refsect1>
96       <title>Examples</title>
97       <screen>
98         (let ((*default-string-length* 80))
99         (def-view-class s80 ()
100         ((a :type string)
101         (b :type (string 80))
102         (c :type varchar))))
103         (create-view-from-class 's80)   
104       </screen>
105       <para>
106         The above code causes a SQL table to be created with the SQL command
107       </para>
108       <screen>CREATE TABLE (A VARCHAR(80), B CHAR(80), C VARCHAR(80))</screen>
109     </refsect1>
110     <refsect1>
111       <title>Affected By</title>
112       <para>Some SQL backends do not support <parameter>VARCHAR</parameter>
113       lengths greater than 255 .</para>
114     </refsect1>
115     <refsect1>
116       <title>See Also</title>
117       <para>None.</para>
118     </refsect1>
119     <refsect1>
120       <title>Notes</title>
121       <para>This is a CLSQL extension to the CommonSQL API.</para>
122     </refsect1>
123   </refentry>
124
125   <refentry id="create-view-from-class">
126     <refnamediv>
127       <refname>CREATE-VIEW-FROM-CLASS</refname>
128       <refpurpose>Create a SQL table from a view class.</refpurpose>
129       <refclass>Function</refclass>
130     </refnamediv>
131     <refsect1>
132       <title>Syntax</title>
133       <synopsis>
134       <function> (create-view-from-class view-class-name &amp;key (database *default-database*) (transactions t))</function> => <returnvalue><!-- no values --></returnvalue></synopsis>
135     </refsect1>
136     <refsect1>
137       <title>Arguments and Values</title>
138       <variablelist>
139         <varlistentry>
140           <term><parameter>view-class-name</parameter></term>
141           <listitem>
142             <para>
143               The name of a view class that has been defined with
144               <link linkend="def-view-class"><function>def-view-class</function></link>.
145             </para>
146           </listitem>
147         </varlistentry>
148         <varlistentry>
149           <term><parameter>database</parameter></term>
150           <listitem>
151             <para>
152               The database in which to create the SQL table.
153             </para>
154           </listitem>
155         </varlistentry>
156         <varlistentry>
157           <term><parameter>transactions</parameter></term>
158           <listitem>
159             <para>
160               When &nil; specifies that a table type which does not support transactions should be used.
161             </para>
162           </listitem>
163         </varlistentry>
164       </variablelist>
165     </refsect1>
166     <refsect1>
167       <title>Description</title>
168       <para>
169         Creates a table as defined by the View Class
170         <parameter>view-class-name</parameter> in <parameter>database</parameter>.
171       </para>
172     </refsect1>
173     <refsect1>
174       <title>Examples</title>
175       <screen>
176         * (def-view-class 'foo () ((a :type (string 80))))
177         #&lt;CLSQL-SYS::STANDARD-DB-CLASS FOO>
178         * (create-view-from-class 'foo)
179         * (list-tables)
180         ("FOO")
181       </screen>
182     </refsect1>
183     <refsect1>
184       <title>Side Effects</title>
185       <para>
186         Causes a table to be created in the SQL database.
187       </para>
188     </refsect1>
189     <refsect1>
190       <title>Affected by</title>
191       <para>
192         Most SQL database systems will signal an error if a table
193         creation is attempted when a table with the same name already
194         exists. The SQL user, as specified in the database connection,
195         must have sufficient permission for table creation.
196       </para>
197     </refsect1>
198     <refsect1>
199       <title>Exceptional Situations</title>
200       <para>
201         A condition will be signaled if the table can not be created
202         in the SQL database.
203       </para>
204     </refsect1>
205     <refsect1>
206       <title>See Also</title>
207       <para>
208         <simplelist>
209           <member><link linkend="def-view-class"><function>def-view-class</function></link></member>
210           <member><link linkend="drop-view-from-class"><function>drop-view-from-class</function></link></member>
211         </simplelist>
212       </para>
213     </refsect1>
214     <refsect1>
215       <title>Notes</title>
216       <para>
217         Currently, only &mysql; supports transactionless
218         tables. &clsql; provides the ability to create such tables for
219         applications which would benefit from faster table access and
220         do not require transaction support.
221       </para>
222       <para>
223         The case of the table name is determined by the type of the
224         database. &mysql;, for example, creates databases in upper-case
225         while &postgresql; uses lowercase.
226       </para>
227     </refsect1>
228   </refentry>
229
230   <refentry id="def-view-class">
231     <refnamediv>
232       <refname>DEF-VIEW-CLASS</refname>
233       <refpurpose>Defines CLOS classes with mapping to SQL database.</refpurpose>
234       <refclass>Macro</refclass>
235     </refnamediv>
236     <refsect1>
237       <title>Syntax</title>
238       <synopsis>
239       <function>(def-view-class name superclasses slots &amp;rest class-options)</function> => <returnvalue>class</returnvalue></synopsis>
240     </refsect1>
241     <refsect1>
242       <title>Arguments and Values</title>
243       <variablelist>
244         <varlistentry>
245           <term><parameter>name</parameter></term>
246           <listitem>
247             <para>
248               The class name.
249             </para>
250           </listitem>
251         </varlistentry>
252         <varlistentry>
253           <term><parameter>name</parameter></term>
254           <listitem>
255             <para>
256               The superclasses for the defined class.
257             </para>
258           </listitem>
259         </varlistentry>
260         <varlistentry>
261           <term><parameter>slots</parameter></term>
262           <listitem>
263             <para>
264               The class slot definitions.
265             </para>
266           </listitem>
267         </varlistentry>
268         <varlistentry>
269           <term><parameter>class</parameter></term>
270           <listitem>
271             <para>
272               The defined class.
273             </para>
274           </listitem>
275         </varlistentry>
276       </variablelist>
277     </refsect1>
278     <refsect1>
279       <title>Slot Options</title>
280       <itemizedlist>
281         <listitem>
282           <para>
283             <parameter>:db-kind</parameter> - specifies the kind of
284             database mapping which is performed for this slot and defaults
285             to <parameter>:base</parameter> which indicates that the
286             slot maps to an ordinary column of the database table. A
287             <parameter>:db-kind</parameter> value of
288             <parameter>:key</parameter> indicates that this slot is
289             a special kind of <parameter>:base</parameter> slot
290             which maps onto a column which is one of the unique keys
291             for the database table, the value
292             <parameter>:join</parameter> indicates this slot
293             represents a join onto another View Class which contains
294             View Class objects, and the value
295             <parameter>:virtual</parameter> indicates a standard
296             CLOS slot which does not map onto columns of the
297             database table.
298           </para>
299         </listitem>
300         <listitem>
301           <para>
302             <parameter>:db-info</parameter> - if a slot is specified with
303             <parameter>:db-kind</parameter> <parameter>:join</parameter>, the
304             slot option <parameter>:db-info</parameter> contains a property list
305             which specifies the nature of the join. The valid members of the list
306             are:
307           </para>
308           <itemizedlist>
309             <listitem>
310               <para>
311                 <parameter>:join-class</parameter>
312                 <emphasis>class-name</emphasis> - the name of the
313                 class to join on.
314               </para>
315             </listitem>
316             <listitem>
317               <para>
318                 <parameter>:home-key</parameter>
319                 <emphasis>slot-name</emphasis> - the name of the slot
320                 of this class for joining
321               </para>
322             </listitem>
323             <listitem>
324               <para>
325                 <parameter>:foreign-key</parameter>
326                 <emphasis>slot-name</emphasis> - the name of the slot
327                 of the <parameter>:join-class</parameter> for joining
328               </para>
329             </listitem>
330             <listitem>
331               <para>
332                 <parameter>:target-slot</parameter>
333                 <emphasis>target-slot</emphasis> - this is an optional
334                 parameter. If specified, then the join slot of the
335                 defining class will contain instances of this target
336                 slot rather than of the join class. This can be useful
337                 when the <parameter>:join-class</parameter> is an
338                 intermediate class in a
339                 <emphasis>many-to-many</emphasis> relationship and the
340                 application is actually interested in the
341                 <parameter>:target-slot</parameter>.
342               </para>
343             </listitem>
344             <listitem>
345               <para>
346                 <parameter>:retrieval</parameter>
347                 <emphasis>time</emphasis> - The default value is
348                 <parameter>:deferred</parameter>, which defers filling
349                 this slot until the value is accessed. The other valid
350                 value is <parameter>:immediate</parameter> which
351                 performs the SQL query when the instance of the class
352                 is created. In this case, the
353                 <parameter>:set</parameter> is automatically set to
354                 &nil;
355               </para>
356             </listitem>
357             <listitem>
358               <para>
359                 <parameter>:set</parameter>
360                 <emphasis>set</emphasis> - This controls what is stored in the join slot.
361                 The default value is &t;. When <emphasis>set</emphasis> is &t; and 
362                 <emphasis>target-slot</emphasis> is undefined, the join slot will contain
363                 a list of instances of the join class. Whereas, if <emphasis>target-slot</emphasis> is defined, 
364                 then the join slot will contain a list of pairs of <emphasis>(target-value join-instance)</emphasis>.
365                 When <emphasis>set</emphasis> is &nil;, the join slot will contain a single instances.
366               </para>
367             </listitem>
368           </itemizedlist>
369         </listitem>
370         <listitem>
371           <para>
372             <parameter>:type</parameter> - for slots of
373             <parameter>:db-kind</parameter> <parameter>:base</parameter> or
374             <parameter>:key</parameter>, the <parameter>:type</parameter> slot
375             option has a special interpretation such that Lisp
376             types, such as string, integer and float are
377             automatically converted into appropriate SQL types for
378             the column onto which the slot maps. This behaviour may
379             be overridden using the <parameter>:db-type</parameter> slot
380             option. The valid values are:
381             <simplelist>
382               <member>
383                 <parameter>string</parameter> - a variable length character field up to
384                 <link linkend="default-string-length">*default-string-length*</link> characters.
385               </member>
386               <member>
387                 <parameter>(string n)</parameter> - a fixed length character field  
388                 <parameter>n</parameter> characters long.
389               </member>
390               <member>
391                 <parameter>varchar</parameter> - a variable length character field up to
392                 <link linkend="default-string-length">*default-string-length*</link> characters.
393               </member>
394               <member>
395                 <parameter>(varchar n)</parameter> - a variable length character field up to
396                 <parameter>n</parameter> characters in length.
397               </member>
398               <member>
399                 <parameter>char</parameter> - a single character field 
400               </member>
401               <member><parameter>integer</parameter> - signed integer at least 32-bits wide</member>
402               <member><parameter>(integer n)</parameter></member>
403               <member><parameter>float</parameter></member>
404               <member><parameter>(float n)</parameter></member>
405               <member><parameter>long-float</parameter></member>
406               <member><parameter>number</parameter></member>
407               <member><parameter>(number n)</parameter></member>
408               <member><parameter>(number n p)</parameter></member>
409               <member>
410                 <parameter>tinyint</parameter> - An integer column 8-bits
411                 wide. [not supported by all database backends]
412               </member>
413               <member>
414                 <parameter>smallint</parameter> - An integer column 16-bits
415                 wide. [not supported by all database backends]
416               </member>
417               <member>
418                 <parameter>bigint</parameter> - An integer column 
419                 64-bits wide. [not supported by all database backends]
420               </member>
421               <member>
422                 <parameter>universal-time</parameter> - an integer
423                 field sufficiently wide to store a
424                 universal-time. On most databases, a slot of this
425                 type assigned a SQL type of
426                 <parameter>BIGINT</parameter>
427               </member>
428               <member>
429                 <parameter>wall-time</parameter> - a slot which
430                 stores a date and time in a SQL timestamp
431                 column. &clsql; provides a number of time
432                 manipulation functions to support objects of type
433                 <type>wall-time</type>.
434               </member>
435               <member>
436                 <parameter>duration</parameter> - stores a <type>duration</type> structure.
437                 &clsql; provides routines for <type>wall-time</type> and <type>duration</type>
438                 processing.
439               </member>
440               <member><parameter>boolean</parameter> - stores a &t; or &nil; value.</member>
441               <member>
442                 <parameter>generalized-boolean</parameter> - similar
443                 to a <parameter>boolean</parameter> in that either a
444                 &t; or &nil; value is stored in the SQL
445                 database. However, any Lisp object can be stored in
446                 the Lisp object. A Lisp value of &nil; is stored as
447                 <constant>FALSE</constant> in the database, any
448                 other Lisp value is stored as
449                 <constant>TRUE</constant>.
450               </member>
451               <member>
452                 <parameter>keyword</parameter> - stores a keyword
453               </member> 
454               <member><parameter>symbol</parameter> - stores a symbol</member>
455               <member>
456                 <parameter>list</parameter> - stores a list by writing it to a string. The items
457                 in the list must be able to be readable written.
458               </member>
459               <member><parameter>vector</parameter> - stores a vector similarly to <parameter>list</parameter></member>
460               <member><parameter>array</parameter> - stores a array similarly to <parameter>list</parameter></member>
461             </simplelist>
462           </para>
463           
464         </listitem>
465         <listitem>
466           <para>
467             <parameter>:column</parameter> - specifies the name of
468             the SQL column which the slot maps onto, if
469             <parameter>:db-kind</parameter> is not
470             <parameter>:virtual</parameter>, and defaults to the
471             slot name. If the slot name is used for the SQL column
472             name, any hypens in the slot name are converted
473             to underscore characters.
474           </para>
475         </listitem>
476         <listitem>
477           <para>
478             <parameter>:void-value</parameter> - specifies
479             the value to store in the Lisp instance if the SQL value is NULL and defaults
480             to NIL.
481           </para>
482         </listitem>
483         <listitem>
484           <para>
485             <parameter>:db-constraints</parameter> - is a string
486             representing an SQL table constraint expression or a
487             list of such strings.
488           </para>
489         </listitem>
490         <listitem>
491           <para>
492             <parameter>:db-type</parameter> - a string to specify the SQL
493             column type. If specified, this string overrides the SQL
494             column type as computed from the <parameter>:type</parameter>
495             slot value.
496           </para>
497         </listitem>
498       </itemizedlist>
499     </refsect1>
500     <refsect1>
501       <title>Class Options</title>
502       <para>
503         <itemizedlist>
504           <listitem>
505             <para>
506               <parameter>:base-table</parameter> - specifies the name of the
507               SQL database table. The default value is the class name. Like slot names,
508               hypens in the class name are converted to underscore characters.
509             </para>
510           </listitem>
511         </itemizedlist>
512       </para>
513     </refsect1>
514     <refsect1>
515       <title>Description</title>
516       <para>
517         Creates a View Class called <parameter>name</parameter> whose
518         slots <parameter>slots</parameter> can map onto the attributes
519         of a table in a database. If
520         <parameter>superclasses</parameter> is &nil; then the
521         superclass of <parameter>class</parameter> will be
522         <parameter>standard-db-object</parameter>, otherwise
523         <parameter>superclasses</parameter> is a list of superclasses
524         for <parameter>class</parameter> which must include
525         <parameter>standard-db-object</parameter> or a descendent of this
526         class.
527       </para>
528
529     </refsect1>
530     <refsect1>
531       <title>Examples</title>
532       <para>
533         The following examples are from the &clsql; test suite.
534       </para>
535       <screen>
536 (def-view-class person (thing)
537   ((height :db-kind :base :accessor height :type float
538            :initarg :height)
539    (married :db-kind :base :accessor married :type boolean
540             :initarg :married)
541    (birthday :type clsql:wall-time :initarg :birthday)
542    (bd-utime :type clsql:universal-time :initarg :bd-utime)
543    (hobby :db-kind :virtual :initarg :hobby :initform nil)))
544   
545 (def-view-class employee (person)
546   ((emplid
547     :db-kind :key
548     :db-constraints :not-null
549     :type integer
550     :initarg :emplid)
551    (groupid
552     :db-kind :key
553     :db-constraints :not-null
554     :type integer
555     :initarg :groupid)
556    (first-name
557     :accessor first-name
558     :type (varchar 30)
559     :initarg :first-name)
560    (last-name
561     :accessor last-name
562     :type (varchar 30)
563     :initarg :last-name)
564    (email
565     :accessor employee-email
566     :type (varchar 100)
567     :initarg :email)
568    (ecompanyid
569     :type integer
570     :initarg :companyid)
571    (company
572     :accessor employee-company
573     :db-kind :join
574     :db-info (:join-class company
575                           :home-key ecompanyid
576                           :foreign-key companyid
577                           :set nil))
578    (managerid
579     :type integer
580     :initarg :managerid)
581    (manager
582     :accessor employee-manager
583     :db-kind :join
584     :db-info (:join-class employee
585                           :home-key managerid
586                           :foreign-key emplid
587                           :set nil))
588    (addresses
589     :accessor employee-addresses
590     :db-kind :join
591     :db-info (:join-class employee-address
592                           :home-key emplid
593                           :foreign-key aemplid
594                           :target-slot address
595                           :set t)))
596   (:base-table employee))
597
598 (def-view-class company ()
599   ((companyid
600     :db-kind :key
601     :db-constraints :not-null
602     :type integer
603     :initarg :companyid)
604    (groupid
605     :db-kind :key
606     :db-constraints :not-null
607     :type integer
608     :initarg :groupid)
609    (name
610     :type (varchar 100)
611     :initarg :name)
612    (presidentid
613     :type integer
614     :initarg :presidentid)
615    (president
616     :reader president
617     :db-kind :join
618     :db-info (:join-class employee
619                           :home-key presidentid
620                           :foreign-key emplid
621                           :set nil))
622    (employees
623     :reader company-employees
624     :db-kind :join
625     :db-info (:join-class employee
626                           :home-key (companyid groupid)
627                           :foreign-key (ecompanyid groupid)
628                           :set t))))
629
630 (def-view-class address ()
631   ((addressid
632     :db-kind :key
633     :db-constraints :not-null
634     :type integer
635     :initarg :addressid)
636    (street-number
637     :type integer
638     :initarg :street-number)
639    (street-name
640     :type (varchar 30)
641     :void-value ""
642     :initarg :street-name)
643    (city
644     :column "city_field"
645     :void-value "no city"
646     :type (varchar 30)
647     :initarg :city)
648    (postal-code
649     :column zip
650     :type integer
651     :void-value 0
652     :initarg :postal-code))
653   (:base-table addr))
654
655 ;; many employees can reside at many addressess
656 (def-view-class employee-address ()
657   ((aemplid :type integer :initarg :emplid)
658    (aaddressid :type integer :initarg :addressid)
659    (verified :type boolean :initarg :verified)
660    (address :db-kind :join
661             :db-info (:join-class address
662                                   :home-key aaddressid
663                                   :foreign-key addressid
664                                   :retrieval :immediate)))
665   (:base-table "ea_join"))
666
667 (def-view-class deferred-employee-address ()
668   ((aemplid :type integer :initarg :emplid)
669    (aaddressid :type integer :initarg :addressid)
670    (verified :type boolean :initarg :verified)
671    (address :db-kind :join
672             :db-info (:join-class address
673                                   :home-key aaddressid
674                                   :foreign-key addressid
675                                   :retrieval :deferred
676                                   :set nil)))
677   (:base-table "ea_join"))
678       </screen>
679     </refsect1>
680     <refsect1>
681       <title>Side Effects</title>
682       <para>Creates a new CLOS class.</para>
683     </refsect1>
684     <refsect1>
685       <title>Affected by</title>
686       <para>
687         Nothing.
688       </para>
689     </refsect1>
690     <refsect1>
691       <title>Exceptional Situations</title>
692       <para>
693         None.
694       </para>
695     </refsect1>
696     <refsect1>
697       <title>See Also</title>
698       <para>
699         <simplelist>
700           <member><link linkend="create-view-from-class"><function>create-view-from-class</function></link></member>
701           <member><link linkend="standard-db-object"><parameter>standard-db-object</parameter></link></member>
702           <member><link linkend="drop-view-from-class"><function>drop-view-from-class</function></link></member>
703         </simplelist>
704       </para>
705     </refsect1>
706     <refsect1>
707       <title>Notes</title>
708       <para>
709         The actual SQL type for a column depends up the database type
710         in which the SQL table is stored. As an example, the view
711         class type <parameter>(varchar 100)</parameter> specifies a
712         SQL column type <parameter>VARCHAR(100)</parameter> in &mysql;
713         and a column type <parameter>VARCHAR2(100)</parameter> in
714         &oracle;
715       </para>
716       <para>
717         The actual lisp type for a slot may be different than the
718         value specified by the <parameter>:type</parameter> attribute.
719         For example, a slot declared with "<parameter>:type (string
720         30)</parameter>" actually sets the slots Lisp type as
721         <parameter>(or null string)</parameter>. This is to allow a
722         &nil; value or a string shorter than 30 characters to be
723         stored in the slot.
724       </para>
725     </refsect1>
726   </refentry>
727
728   <refentry id="drop-view-from-class">
729     <refnamediv>
730       <refname>DROP-VIEW-FROM-CLASS</refname>
731       <refpurpose>Delete table from SQL database.</refpurpose>
732       <refclass>Function</refclass>
733     </refnamediv>
734     <refsect1>
735       <title>Syntax</title>
736       <synopsis>
737       <function>(drop-view-from-class view-class-name &amp;key (database *default-database*))</function> => <returnvalue><!-- result --></returnvalue></synopsis>
738     </refsect1>
739     <refsect1>
740       <title>Arguments and Values</title>
741       <variablelist>
742         <varlistentry>
743           <term><parameter>view-class-name</parameter></term>
744           <listitem>
745             <para>
746               The name of the view class.
747             </para>
748           </listitem>
749         </varlistentry>
750       </variablelist>
751     </refsect1>
752     <refsect1>
753       <title>Description</title>
754       <para>Removes a table defined by the View Class
755       <parameter>VIEW-CLASS-NAME</parameter> from
756       <parameter>DATABASE</parameter> which defaults to
757       <parameter>*DEFAULT-DATABASE*</parameter>.
758       </para>
759     </refsect1>
760     <refsect1>
761       <title>Examples</title>
762       <screen>
763         * (list-tables)
764         ("FOO" "BAR")   
765         * (drop-view-from-class 'foo)
766         * (list-tables)
767         ("BAR") 
768       </screen>
769     </refsect1>
770     <refsect1>
771       <title>Side Effects</title>
772       <para>
773         Deletes a table from the SQL database.
774       </para>
775     </refsect1>
776     <refsect1>
777       <title>Affected by</title>
778       <para>
779         Whether the specified table exists in the SQL database.
780       </para>
781     </refsect1>
782     <refsect1>
783       <title>Exceptional Situations</title>
784       <para>
785         A condition may be signalled if the table does not exist in
786         the SQL database or if the SQL connection does not have
787         sufficient permissions to delete tables.
788       </para>
789     </refsect1>
790     <refsect1>
791       <title>See Also</title>
792       <para>
793         <simplelist>
794           <member><link linkend="create-view-from-class"><function>create-view-from-class</function></link></member>
795           <member><link linkend="def-view-class"><function>def-view-class</function></link></member>
796         </simplelist>
797       </para>
798     </refsect1>
799     <refsect1>
800       <title>Notes</title>
801       <para>
802         <!-- notes --> 
803       </para>
804     </refsect1>
805   </refentry>
806
807   <refentry id="list-classes">
808     <refnamediv>
809       <refname>LIST-CLASSES</refname>
810       <refpurpose>List classes for tables in SQL database.</refpurpose>
811       <refclass>Function</refclass>
812     </refnamediv>
813     <refsect1>
814       <title>Syntax</title>
815       <synopsis>
816       <function>(list-classes &amp;key (test #'identity) (root-class (find-class 'standard-db-object)) (database *default-database*))</function> => <returnvalue>classes</returnvalue></synopsis>
817     </refsect1>
818     <refsect1>
819       <title>Arguments and Values</title>
820       <variablelist>
821         <varlistentry>
822           <term><parameter>test</parameter></term>
823           <listitem>
824             <para>
825               a function used to filter the search. By default, <parameter>identity</parameter> is used which
826               will return all classes.
827             </para>
828           </listitem>
829         </varlistentry>
830         <varlistentry>
831           <term><parameter>root-class</parameter></term>
832           <listitem>
833             <para>
834               specifies the root class to the search. By default, <parameter>standard-db-object</parameter> is used
835               which is the root for all view classes.
836             </para>
837           </listitem>
838         </varlistentry>
839         <varlistentry>
840           <term><parameter>database</parameter></term>
841           <listitem>
842             <para>
843               The database to search for view classes.
844             </para>
845           </listitem>
846         </varlistentry>
847         <varlistentry>
848           <term><parameter>classes</parameter></term>
849           <listitem>
850             <para>
851               List of view classes.
852             </para>
853           </listitem>
854         </varlistentry>
855       </variablelist>
856     </refsect1>
857     <refsect1>
858       <title>Description</title>
859       <para>Returns a list of all the View Classes which have been
860       defined in the Lisp session and are connected to
861       <parameter>database</parameter> and which descended from the
862       class <parameter>root-class</parameter> and which satisfy the
863       function <parameter>test</parameter>.
864       </para>
865     </refsect1>
866     <refsect1>
867       <title>Examples</title>
868       <screen>
869         * (list-classes)
870         (#&lt;clsql-sys::standard-db-class big> #&lt;clsql-sys::standard-db-class employee-address>
871         #&lt;clsql-sys::standard-db-class address> #&lt;clsql-sys::standard-db-class company> 
872         #&lt;clsql-sys::standard-db-class employee>)
873
874         * (list-classes :test #'(lambda (c) (> (length (symbol-name (class-name c))) 3)))
875         (#&lt;clsql-sys::standard-db-class employee-address> #&lt;clsql-sys::standard-db-class address>
876         #&lt;clsql-sys::standard-db-class company> #&lt;clsql-sys::standard-db-class employee>)
877       </screen>
878     </refsect1>
879     <refsect1>
880       <title>Side Effects</title>
881       <para>
882         None.
883       </para>
884     </refsect1>
885     <refsect1>
886       <title>Affected by</title>
887       <para>
888         <simplelist>
889           <member>Which view classes have been defined in the Lisp session.</member>
890         </simplelist>
891       </para>
892     </refsect1>
893     <refsect1>
894       <title>Exceptional Situations</title>
895       <para>
896         None.
897       </para>
898     </refsect1>
899     <refsect1>
900       <title>See Also</title>
901       <para>
902         <simplelist>
903           <member><link linkend="def-view-class"><function>def-view-class</function></link></member>
904         </simplelist>
905       </para>
906     </refsect1>
907   </refentry>
908
909
910 </reference>