SQLite missing database - sql

I have two database named Main and OutputTax using Firefox SQLite database.My aim is to update database in OutputTax while data in Main is input by selecting certain columns.
The columns in Main are "Date", "Particular", "InvNoSimp", "InvNoFull", "AmountTaxSimp", "GSTSimp", "AmountTaxFull"
While I just need "Date","Particular","InvNoSimp","AmountTaxSimp", "GSTSimp", in OutPutTax database.
String query="insert into OutputTax SELECT
Date,Particular,InvNoSimp,AmountTaxSimp,GSTSimp, from Main";
Whenever I call this query, It shows Query does not return results.
Can anybody tell me what is the problem? Thank you, your answer is much appreciated!

Have you tried this
insert into OutputTax( Date,Particular,InvNoSimp,AmountTaxSimp,GSTSimp) SELECT
Date,Particular,InvNoSimp,AmountTaxSimp,GSTSimp from Main;

Related

Best way to duplicate data in the same table and updating a column at the same time

I'm trying to find the best way to duplicate all the rows in a table.By this i mean inserting them again in the same table, but i need to update a single column only on the values that were inserted.
This is to help me write a script so I can automate some work on some clients.
I can't use select * as it will throw an error because of the identity columns but at the same time i don't want to be manually writting all the column names for several tables.
Is there a simple way to translate this into SQL server?
Sorry for not showing a piece of code, but i have nothing at the moment and i'm not really fluent in SQL.
EDIT: I have ended up following the advice of JamieD77 in the comments below this post by moving everything to a table, drop the id column, updating what i need and then moving back as it seems to be the most effiecient.
In SQL Server Management Studio you can drag the "Columns" folder under a table and drop it on the query window and it will paste a comma-delimited list of all the columns.
Or run a query like:
select string_agg(quotename(name),', ')
from sys.columns
where object_id = object_id('MyTable')

How can I stop my SQL from returning empty data results?

I usually use Toad to manipulate my Oracle databases, but I even tried SQL manager for this one and it still would not work. I have a table with a few hundred records, and even running a simple
SELECT * FROM customer
will not work. There are no errors, and the data grid that displays pulls all the correct field column names but there are no records shown. What could be causing this?
Does your login schema own the table? If not, verify that any synonym is actually pointing to the object that you think it is. Preface the table name with its owning schema to rule out any conflicts.

Does using regular expressions in a SQL Select statement change real data?

select orderid from orders where REGEXP_REPLACE(orderid,'/^0+(.)/')
I have searched the documentation and am missing it. If I run this query will it change any real data or just my set returned for output (the "virtual" data)? The word replace scares me. I am using oracle 11g.
Thank you.
Because you are performing a SELECT, you end up getting a read only view of the data, nothing has changed.
So you don't need to worry about running this select statement. The only way to update it would be to follow this up with an UPDATE command.
No, it doesn't. (even though this answer is too short for SO).

How can I see where data in a column comes from?

I don't know if anyone can help me. In my job, I inherited a completely undocumented database (Oracle 11). So far, I've managed to map most of the tables and determine what's going on where. However, there are a few columns that I haven't been able to decipher.
Is there some way of finding out how is the data in the column built? This is not a manual input. Everything seems to point to the data being the result of an entry in a different column in a completely different table.
It might be an impossible task, but any and all suggestions will be more than welcome.
Thanks!
C
Perhaps the data is being inserted in your mystery columns via a trigger? Try looking in the PL/SQL source table in the dictionary:
SELECT owner, name, type, line
FROM dba_source
WHERE UPPER(text) LIKE '%MYSTERY_COLUMN_NAME%'
AND type = 'TRIGGER'; -- use or omit this as desired.
This will get you pointed in some possible places to look.
Good luck!
You can retrieve the complete DDL for a table using the DBMS_METADATA package.
SELECT dbms_metadata.get_ddl('TABLE', 'YOUR_TABLE_NAME', 'YOUR_USER_NAME')
FROM dual;
If those columns are really computed columns then this should be visible in the DDL for the table.
Alternatively you can use SQL Developer to show the DDL for the table
I am presuming that you already have the sql that is in question.
select table_name from dba_tab_columns
where column_name = 'COLUMN_YOU_WANT_TO_KNOW'
will provide all tables that contain a column name that you are looking for. If you do not have dba privileges you can use all_tab_columns instead (which will show all tables your account would have access to).

how to select a particular table from a storedprocedure which returns multiple table?

I have a storedproc which has multiple select statement.
When it is executed in sql server , it returns multiple tables.
I need a query which will select a particular table from the storedproc e.g. sp_help.
Please help.
If i have a look at this link, it seems that it is not possible.
Astander is right. From the number of tables available in ur SP, it is not possible directly.
However, you can apply some trick to accomplish your work. I am giving an example here. May be you can generate some idea based on this line.
SELECT * FROM sys.Tables where name =
'my_tbl'
As you can make out that I am filtering out the query by a table among all the tables available in my database.
Something of this sort may help you.
Else, if can get the dataset and then from that get the needed datatable from ur frontend code.