Not able to query after Alter table in DB2 - db2

We have a table someone created in DB2. I have no idea how they created it. But when I edit the table, It edits just fine. But after edit I can not query the table at all THE COLUMN CANNOT BE ADDED TO THE TABLE BECAUSE THE TABLE HAS AN EDIT PROCEDURE.
I looked ibm site and found this how to edit table using procedure
But I have no idea how to do this.
Is there anything that I can do to fix this with out following the procedure mentioned in second link?
I restarted server, but still no help. First I'm not able to figure out why I get the error in first place.
I'm using DB Visualizer and DB2 on linux.

This is sometimes default behavior of DB2. We need to run reorgchk command to fix these errors. More info below..
http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/r0000888.htm
http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/c0023297.htm

Related

Can't select from database without specifying schema name

I am new to databases and I was trying to set up PostreSQL and trying to query
tables in pgAdmin 4, but I always have to specify schema name as such:
SELECT * FROM infection_database.country
The database name is the same as the schema name. This is probably not good but I didn't know better.
I tried looking up some solutions and found and tried this, but it didn't fix the issue:
ALTER DATABASE infection_database SET search_path="infection_database";
Tried both with and without quotation marks if it matters. Where am I making a mistake?
Given solution works, but you need to restart the session for the changes to take effect.
Credit to #jjanes

, Drop column Error ora-00933 sql command not properly ended

I need to drop an column in my existing table. Not sure why below syntax is not working for me and getting 'ora-00933 sql command not properly ended'
DB Query:
ALTER TABLE employee DROP COLUMN TITLE;
Please suggest. Using oracle 12c version.
Thanks #learningloop for suggestions.
I tried after removing the semi-colon in the SQL and it worked out. I was using toad editor for the query execution.

Linking MS Access table to PG Admin schema

I would like to link a MS Access table to a table in PG admin if it is possible for use in a Postgres query. I have searched for an answer but all I can find is answers for listing postgres tables in Access which is almost the opposite of what I want to do.
I want to be able to access the data entered in an access form without having to continually import the data into a table in PG Admin.
I'm not even sure that is possible but any method that is easier than importing the table into PG Admin every day would be useful.
Thanks
Gary
Try the PostgreSQL OGR Foreign Data Wrapper. Its built for spatial data, but it works perfectly well with non-spatial tables. If you have the PostGIS extension installed you will already have it.
https://github.com/pramsey/pgsql-ogr-fdw
There are several examples on that page, but the command
ogr_fdw_info -s <pathToAccessFile> -l <tablename>
will return create server and a create foreign table statements which you can edit as required then run in pgAdmin.

how to copy derby table

I am using Eclipse, Java and a Derby database. I want to experiment with changing values that rewrite one of the tables in the db. Before starting the change I would like to copy the particular table (not in code) so that I can restore the original data if necessary. Sof ar googling and searching this site hasnt produced an answer. In Eclipse there is an option to export the db but it calls it a connection so I am not usre what would happen.
If you're not sure about how to connect to the database and issue sql statements, you will need to learn about JDBC. This is a good place to start.
If you're asking about the SQL, it's pretty straight forward. You can create a table based on a select statement.
e.g.
create table table2 as select * from table1 with no data;
Derby is a little strange in this area. You must specify the with no data, and the created table will be empty. You can then issue an insert that will populate the new table if you wish.
insert into table2 select * from table1;
The new table will not have indexes. You will need to create them if you want them. It might retain the primary key. You should check that if you're testing against it. If it doesn't retain the primary key, you should create the primary key before inserting data into the table.
In Eclipse there is an option to export the db but it calls it a connection so I am not sure what would happen.
If what Eclipse does isn't clear for you, you can just as well zip your entire database directory (content of DERBY_HOME env. variable) into an archive. The database must not be running while you make the backup.

Mysterious disappearance of an Index in an Oracle 10g table

I have a table in an Oracle database. An Index has mysteriously disappeared. Is there any way to find out how that happened? I am using Toad for Oracle Version 9.5.0.31
Thanks
I'm not sure you can find out after the fact but you can log future DROPs"
CREATE or replace TRIGGER your_name AFTER DROP
ON your_schema
pl/sql_block
You'll also have to create a logging table and insert into it.