After you install Oracle 11g XE, it will automatically create some tables (from what I've read, some are used for "Application Express", and you shouldn't drop them), but having them listed in Tables view is really annoying.
Is there a way to filter them out? And why do you use $ in table name for?
For some reason, last time I searched on google it didn't showed me anything useful (on any of the first 4 pages), but this time, I got the answer I needed.
1. Use a different user then SYSTEM. I didn't though at this, after all I didn't wanted to complicate things on a learning project.
2. Filter each group using %. When I tried it before it didn't worked, but now after I started the DB again, the filter worked as it should have. Maybe there was an error connecting to the DB, don't know, it's good that now it is working.
When i execute the procedure what i get the output is like -
ALTER PROC [dbo].[PROC_EMPLOYEE_PAY_SLIP]
@MonthName varchar(50), @Year Float
SELECT ISNULL(HR_EmployeeMaster.em_EmplopyeeCode,'') As EmplopyeeCode,
ISNULL(CASE WHEN fa_ComponentMaster.Cm_ADTag = 'A' THEN fa_ComponentMaster.Cm_Name ELSE '' END,'') As Additions,
ISNULL(CASE WHEN fa_ComponentMaster.Cm_ADTag = 'D' THEN fa_ComponentMaster.Cm_Name ELSE '' END,'') As Deductions,
ISNULL(CASE WHEN fa_ComponentMaster.Cm_ADTag = 'A' THEN Fa_MonthSalary.Ms_Amount ELSE 0 END,0) As AdditionsAmount,
ISNULL(CASE WHEN fa_ComponentMaster.Cm_ADTag = 'D' THEN Fa_MonthSalary.Ms_Amount ELSE 0 END,0) As DeductionsAmount
LEFT JOIN Fa_MonthSalary ON Fa_MonthSalary.ms_EmpCode = @EmplopyeeCode
LEFT JOIN Fa_MonthDetails ON Fa_MonthDetails.mo_id = Fa_MonthSalary.Ms_MonCode
LEFT JOIN fa_ComponentMaster ON fa_ComponentMaster.cm_code = Fa_MonthSalary.Ms_CompCode
WHERE HR_EmployeeMaster.em_EmplopyeeCode = @EmplopyeeCode AND
(SELECT CONVERT(CHAR(3), Fa_MonthDetails.mo_name)) = @MonthName AND
Fa_MonthDetails.mon_year = @Year
You do have the mongo cli, which allows you to query the data, etc. But there is no "shape" to the data, like there is with SQL Data. Mongodb has "collections" which are roughly equivalent to tables, but unlike SQL tables, they have no structure imposed on them. e.g.
If you have a Mongodb where collections do not have some specific form then you are using it wrong.
Besides the CLI I have also used two different UI clients for Mongo and both show the data that are in the collections in a reasonable way.
Now if you are starting with a empty collection you won't know what will go in there and with a SQL table you would but that that is somewhat a matter of degree and not usability. In that case you should go look to your design, which you should have regardless, or the code.
You'll need to use a command like
"DELETE FROM EVENTI WHERE (condition)",
but we can't tell you what that condition is, since we don't know the table structure.
You can't think of SQL tables like flat files. Successive SELECTS from a table won't necessarily return the rows in the same order.
All tables should have a PRIMARY KEY, which uniquely identifies a given row. You should be able to use this to select the rows you wish to delete. Alternatively you may have a timestamp or other identifying piece of information in the row that will help you choose which rows to delete.
I have not set a PRIMARY KEY in my table but the "DataOra" column contains a timestamp in the form "YYYY/MM/DD hh:mm:ss" so I think I could use this information to select the rows to delete.
But to do this I need to read the value of row 5000 without any information about this row, I mean that I have not a PRIMARY KEY and I just know the row number, is this information enought to read row 5000?
And if I read row 5000, then I can use a command like:
"DELETE FROM EVENTI WHERE DataOra < 'YYYY/MM/DD hh:mm:ss'"
You should probably use a DATETIME field type for DataOra, but if you know that all your timestamps are 'YYYY/MM/DD hh:mm:ss', then then comparing as strings should work out OK.
How you truncate your data is somewhat dependent on exactly what your need is. If you just want to delete approximately 5000 records, you could do
SELECT count(*) FROM EVENT where DataOra < 'YYYY/MM/DD 00:00:00'
and adjust the date and or time up/down until you get about 5000 and then use that date as your comparison. Or maybe you would be happy with just deleting records before Feb 01/2019 in which case you could just use '2019/02/01 00:00:00' as your comparison
Alternatively, if you want to delete exactly 5000 records, ordering by timestamps, then this might work for you:
CREATE TEMP TABLE TMP(id INTEGER PRIMARYKEY AUTOINCREMENT, DataOra text);
INSERTINTO TMP(DataOra) SELECT DataOra from EVENT orderby DataOra;
DELETEFROM EVENT where DataOra <= (SELECT DataOra from TMP where id = 5000);
hope this helps. Don't forget to back up your data before you begin - just in case!
In my example the TMP table is created with the attribute TEMP, which means that the table will be TEMPORARY, and are dropped when the connection that created them closes. TEMP tables are created in the "temp" database (as per sqlite docs). Other than only existing for the current session, TEMP tables are just like regular tables - they can be indexed, altered, updated, etc.
If "DataOra" or "Evento" are not your line numbering system then you have a problem.
Assuming there is some sort of sequence in your data, date or number you could select the top 50000, get the sequence value and then delete anything less than the selected sequence. I would test this on a copy of the database
given a table job with columns time_utc (datetime) and state (integer), i want to find the periods (start-time and end_time) where the consequetive value of the state column equals 4.
i tried to find the start of the periods with the folllowing query, but no success. too many results.
can someone please help me? i cannot figure it out.
SELECT act_start_time_utc, state_cd FROM SRPMES901007.WWMESDB.dbo.job WHERE act_start_time_utc ISNOTNULLORDERBY act_start_time_utc ASCDECLARE@PERIODTABLE (start_time DATETIME, end_time DATETIME)
SELECT t.start_time/*, t.new_state, t.last_state*/FROM (
SELECT act_start_time_utc AS start_time, state_cd AS new_state, LAG(state_cd, 1) OVER (ORDERBY act_start_time_utc ASC) AS last_state
WHERE act_start_time_utc ISNOTNULL) AS t
WHERE t.new_state = 4AND t.last_state <> 4UPDATE period
SET end_time = (SELECT MIN(act_start_time_utc) endtime FROM SRPMES901007.WWMESDB.dbo.job INNERJOIN@PERIOD period ON job.act_start_time_utc > period.start_time AND state_cd <> 4)
SELECT * FROM@PERIODORDERBY start_time ASC
modified 9-Feb-19 16:10pm.
Last Visit: 31-Dec-99 19:00 Last Update: 10-Dec-23 10:11