PgsqlTable_DropIfExists1
Creating Visitor11 table in PostgreSQL
  • Code Highlights:
    • String sqlCreate = "create table pgsVisitor1A" + "(id NUMERIC(3) CONSTRAINT PK_v1A PRIMARY KEY,"
      + "fname varchar(30)," + "lname varchar(30),"
      + "age numeric(2)) ";
    • String sqldrop= "drop table if exists pgsVisitor1A;";
    • String sqlQuery ="Select * from pgsVisitor1A";
      //create table visitor11 ("id int," + "fname varchar(30)," + "lname varchar(30)," + "age int(2))";
    • String strInsert1 ="INSERT INTO pgsVisitor1A values (101,'John', 'Doe', 40)";
      String strInsert2 ="INSERT INTO pgsVisitor1A values(102,'Peter', 'Pan', 44)";
       
    • // connection>>statement >> Resultset
      c = DriverManager.getConnection(dbURL,user,pwd);
      // drop table if exists visitor1A;
      st = c.createStatement();
      st.execute(sqldrop);
       
 
pgsAdmin III view prior to adding a new table :

Snapshot  of the table (at pgsAdminIII widnow) during  thread-sleeping for a period of 500000:

Code generated at  : in pgsAdminIII]


-- DROP TABLE pgsvisitor1a;

CREATE TABLE pgsvisitor1a
(
id numeric(3,0) NOT NULL,
fname character varying(30),
lname character varying(30),
age numeric(2,0),
CONSTRAINT pk_v1a PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE pgsvisitor1a
OWNER TO postgres;

 

NetBean 8.0 Output view during the sleep

pgsvisitors1a table after drop execution after thread-sleep period

NetBean 8.0 view after complete operation:

Code used in : PgsqlTable_DropIfExists1.txt