You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Sam Aoudi <ao...@hotmail.com> on 2011/01/06 09:25:42 UTC

how to show all tables in current schema without using ij tool?

Hi,


I am struggling with issues when it comes to Apache derby:
1-  I haven't been able to get a list of Tables in a schema without using ij. Is this feasible?
2- I haven't been able to use "On Delete Cascade", any good examples are appreciated.

Thanks
 		 	   		  

RE: how to show all tables in current schema without using ij tool?

Posted by Sam Aoudi <ao...@hotmail.com>.
Thanks Matt and Emmanuel,

The Show table issue is resolved.

 However still working on delete issue.

Date: Thu, 6 Jan 2011 08:29:12 -0700
Subject: FW: how to show all tables in current schema without using ij tool?
From: Matt.Pouttu-Clarke@icrossing.com
To: aoudi_s@hotmail.com





Message body


Hi Sam,



This comment also addresses your questions I hope...



Cheers,

Matt



------ Forwarded Message

From: Matt Pouttu-Clarke <Ma...@icrossing.com>

Reply-To: Derby Discussion <de...@db.apache.org>

Date: Thu, 06 Jan 2011 08:17:46 -0700

To: Derby Discussion <de...@db.apache.org>

Cc: Sam Aoudi <ao...@hotmail.com>

Subject: Re: how to show all tables in current schema without using ij tool?



Hi Emmanuel,



For number 1:

            Connection conn = DriverManager.getConnection("jdbc:derby:<db name>");  

            ResultSet tables = conn.getMetaData().getTables(null, null, null, null);

            while(tables.next()) {

                System.out.println(tables.getString("TABLE_NAME"));

            }

            tables.close();



For number 2: I don’t know because I never use cascading DB constraints, as they don’t scale to any significant data sizes.  However if you need cascading constraints with more scalability, try using a O/R mapping framework such as Hibernate...



Cheers,

Matt





On 1/6/11 5:34 AM, "Emmanuel Cecchet" <ma...@frogthinker.org> wrote:



   Hi,

 

I am struggling with issues when it comes to Apache derby:

 1-  I haven't been able to get a list of Tables in a schema without using ij. Is this feasible?

 

 SELECT * FROM SYS.SYSTABLES 

2- I haven't been able to use "On Delete Cascade", any good examples are appreciated.

  

 CREATE TABLE a (pk INT NOT NULL CONSTRAINT a_pk PRIMARY KEY)

 CREATE TABLE b (x LONG VARCHAR, id INT CONSTRAINT b_fk REFERENCES a(pk) ON DELETE CASCADE)

 INSERT INTO a VALUES (1)

 INSERT INTO b VALUES ('hello', 1)

 SELECT * FROM a,b

   

 PK X ID  

 1 hello 1    DELETE FROM b

 SELECT * FROM a,b

   

 PK X ID    

 

 Hope this helps,

 Emmanuel

 




iCrossing Privileged and Confidential Information

This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information of iCrossing. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.






------ End of Forwarded Message




iCrossing Privileged and Confidential Information
This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information of iCrossing. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. 		 	   		  

Re: how to show all tables in current schema without using ij tool?

Posted by Matt Pouttu-Clarke <Ma...@icrossing.com>.
Hi Emmanuel,

For number 1:
            Connection conn = DriverManager.getConnection("jdbc:derby:<db
name>");  
            ResultSet tables = conn.getMetaData().getTables(null, null,
null, null);
            while(tables.next()) {
                System.out.println(tables.getString("TABLE_NAME"));
            }
            tables.close();

For number 2: I don¹t know because I never use cascading DB constraints, as
they don¹t scale to any significant data sizes.  However if you need
cascading constraints with more scalability, try using a O/R mapping
framework such as Hibernate...

Cheers,
Matt


On 1/6/11 5:34 AM, "Emmanuel Cecchet" <ma...@frogthinker.org> wrote:

>    Hi,
>  
>> I am struggling with issues when it comes to Apache derby:
>>  1-  I haven't been able to get a list of Tables in a schema without using
>> ij. Is this feasible?
>>  
>  SELECT * FROM SYS.SYSTABLES
>> 2- I haven't been able to use "On Delete Cascade", any good examples are
>> appreciated.
>>   
>  CREATE TABLE a (pk INT NOT NULL CONSTRAINT a_pk PRIMARY KEY)
>  CREATE TABLE b (x LONG VARCHAR, id INT CONSTRAINT b_fk REFERENCES a(pk) ON
> DELETE CASCADE)
>  INSERT INTO a VALUES (1)
>  INSERT INTO b VALUES ('hello', 1)
>  SELECT * FROM a,b
>    
>  PK X ID  
>  1 hello 1    DELETE FROM b
>  SELECT * FROM a,b
>    
>  PK X ID    
>  
>  Hope this helps,
>  Emmanuel
>  


iCrossing Privileged and Confidential Information
This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information of iCrossing. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.



Re: how to show all tables in current schema without using ij tool?

Posted by Emmanuel Cecchet <ma...@frogthinker.org>.
Hi,
> I am struggling with issues when it comes to Apache derby:
> 1-  I haven't been able to get a list of Tables in a schema without 
> using ij. Is this feasible?
SELECT * FROM SYS.SYSTABLES
> 2- I haven't been able to use "On Delete Cascade", any good examples 
> are appreciated.
CREATE TABLE a (pk INT NOT NULL CONSTRAINT a_pk PRIMARY KEY)
CREATE TABLE b (x LONG VARCHAR, id INT CONSTRAINT b_fk REFERENCES a(pk) 
ON DELETE CASCADE)
INSERT INTO a VALUES (1)
INSERT INTO b VALUES ('hello', 1)
SELECT * FROM a,b
PK 	X 	ID
1 	hello 	1

DELETE FROM b
SELECT * FROM a,b
PK 	X 	ID



Hope this helps,
Emmanuel

-- 
Emmanuel Cecchet
FTO @ Frog Thinker
Open Source Development&  Consulting
--
Web: http://www.frogthinker.org
email: manu@frogthinker.org
Skype: emmanuel_cecchet