|
How can I get the number of the tables from a sqlite3 database ?
I downloaded from here: SQLite Sample Database And Its Diagram (in PDF format)[^]
chinook.db
But when I try to get all tables from this database:
SELECT * FROM sqlite_schema WHERE type = 'table' AND name NOT LIKE 'sqlite_%'
I got:
no such table: sqlite_schema
I also tried to create a database on my own:
SQLite::Database db("C:\\Temp\\mydb.bd3", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
db.exec(_T("CREATE TABLE sqlite_schema(type TEXT, name TEXT, tbl_name TEXT, rootpage INTEGER, sql TEXT)"));
db.exec(_T("PRAGMA foreign_keys = ON"));
and
db.exec(_T("DROP TABLE IF EXISTS master"));
db.exec(_T("CREATE TABLE master(masterid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name TEXT)"));
db.exec(_T("DROP TABLE IF EXISTS app"));
db.exec(_T("CREATE TABLE app (appid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name TEXT)"));
db.exec(_T("DROP TABLE IF EXISTS device"));
db.exec(_T("CREATE TABLE device (deviceid INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, masterid INTEGER, appid INTEGER, name TEXT, FOREIGN KEY(masterid) REFERENCES master(masterid), FOREIGN KEY(appid) REFERENCES app(appid))"));
but when I try the same SQL:
SELECT * FROM sqlite_schema WHERE type = 'table' AND name NOT LIKE 'sqlite_%'
I got the same error:
no such table: sqlite_schema
How can I assure to retrieve all tables from a db3 (db ) file ?
|
|
|
|
|
The name has been changed to "sqlite_schema " as of version 3.33.0. The older name "sqlite_master " is still accepted as an alias for backwards compatibility. The FAQ is for version 3.33.0. You must be using an older version of SQLite.
Assuming you're not using 3.33.0 or later, try using the sqlite_master table instead.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks a lot. That was the issue.
I have a small request: can you share which structure has this table, sqlite_master ?
I need a database_id , table_id , or appropriate.
|
|
|
|
|
|
Hello all
i have stored procedure running fine in MS sql 2012 but when i run it in ms sql 2018 i got this error message:
The data types datetime and time are incompatible in the add operator.
this is the line of the error :
(CONVERT(datetime, shfts.Date) + SftpStartTime) as SftStartDateTime,
case when ((CONVERT(datetime, shfts.Date) +SftpEndTime)
> (CONVERT(datetime, shfts.Date) + SftpStartTime) )
|
|
|
|
|
I think you'll have to use the DATEADD function instead of just the addition operator.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Your problem is occurring because you cannot add time to a date using columns or variables - although you can do it with literals - but only if you convert the date to a datetime This is valid - but doesn't help you I know, just putting it out there
select convert(datetime, shftsDate) + '16:12:00' SftStartDateTime is obviously just a time so you can't use the DateAdd function - if you try you will get another error Quote: Argument data type time is invalid for argument 2 of dateadd function. Converting that time into "seconds from midnight" could be an option, but that is a real PITA - Google for it and see how awful the solutions are
The solution is to ensure that both operands of are of the same type. E.g.
select convert(datetime, @shftsDate) + convert(datetime, @SftpStartTime);
|
|
|
|
|
|
Check your database compatibility level - it's likely that you had it set to 100 on your SQL Server 2012 instance, but it's set to 110 or higher on your SQL Server 2016/2019 instance.
(NB: There is no SQL Server 2018 version.)
As a temporary workaround, you may be able to set the compatibility level back to 100 . But this will prevent you from using any features introduced after SQL Server 2008.
The correct fix would be to change your code to use DATEADD instead:
DATEADD(second, DATEDIFF(second, 0, SftpStartTime), shfts.Date) As SFtStartDateTime,
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Is this app like 3rd party cookies?
|
|
|
|
|
|
Don't get you question. Can you please elaborate?
|
|
|
|
|
a network-related or instance-specific error occured while establishing a connection to SQL Server.
the server was not found or was not accessible. very that the instance name is correct and that SQL Server
is configured to allow remote connections.(Provider:Names pipes provider, error:40 - could not open a connection
to sql server ) (Microsoft sql server, error:53)
|
|
|
|
|
Please stop reposting this message. You have been told more than once what you need to do to resolve this.
|
|
|
|
|
|
Hello all. If you own an Oracle DB, could you provide me two queries?
First, get database_id and name for every database, something like this (in MSSQL):
SELECT database_id, name FROM sys.databases ORDER BY 2
and the second one, that provide every table from a database, something like that (in MSSQL):
SELECT table_name FROM %s.information_schema.tables ORDER BY 1
where %s is the database name taken from the first query.
Thank you.
|
|
|
|
|
In Oracle, the equivalent for SQL Server's information_schema or sys tables would be the DICTIONARY and dynamic performance views - (https://docs.oracle.com/cd/E11882_01/server.112/e40540/datadict.htm#CNCPT002)
Your first query doesn't make sense in an Oracle context since in Oracle you only connect to one database at a time.
The second could be (to list the tables in the connected database):
SELECT * FROM ALL_TABLES;
SELECT * FROM DBA_TABLES;
depending on your rights. See the link for the difference.
modified 15-Dec-21 8:07am.
|
|
|
|
|
Thank you Scott, so, in Oracle it is not possible to list all databases ?
|
|
|
|
|
I confess I use SQL Server more these days than Oracle, but the only possible option I can find that would let you see multiple databases seems to be if you're using something like Enterprise Manager Cloud Control - https://www.mydbaworld.com/extract-databases-server-os-version-of-oem-repository/]">Extract the list of all databases with server and OS version of Oracle Enterprise Manager Cloud Control repository - My DBA World
|
|
|
|
|
I'm a new Dev.
I wanted to learn more about how google classrooms database works, Like when a student enters a Code it will then proceed to the classroom and displays all the data on that classroom? I want to learn, how does that work. Would love to hear some suggestions on where to learn more about how it works.
|
|
|
|
|
|
Good day,
How could I go about justifying a Data Warehouse for the business when there are already detailed transaction log tables in the OLTP database.
I would need to give examples of why a Data Warehouse would give more and better answers when there is already a history of all updates done on "Product" as an example.
In other words. What do I put in the Data Warehouse which is not already in the transaction log tables.
Maybe someone can provide some valuable answers.
|
|
|
|
|
I think the first thing to point out would be ..."how do you intend to get that information back out of the transaction log tables in a timely and usable way?"
There are many many resources on line that will present the argument for you e.g. Top 10 Benefits of a Data Warehouse | Datamation[^] amongst millions of others[^]
|
|
|
|
|
Thank you for the reply and for the link ....
Yes, I understand. One of the most popular arguments for having Data Warehouse is that it should enable the user to access data/information faster.
I have been thinking about these points (Benefits of having a data Warehouse) for a long time now. At the moment we do not have a very large business or production database. The largest of tables transaction log) consist of around 8 million records with 40 fields. So, I don't think speed of access is our problem however, I do agree with some of the other benefits like:
2. Enhances Conformity And Quality Of Data
3. Boosts Efficiency "to have to gather data from multiple sources"
In our case we have many different types of databases (data islands) most of them SQL Server... So, I think that the DW would solve the challenge of bringing everything together in order to give the user a better view of how the business when all data is brought together into one view ("to have to gather data from multiple sources").
Again, thank you for the reply and the information ....
|
|
|
|
|
Quote: Boosts Efficiency "to have to gather data from multiple sources" It also lowers frustration!
After I had posted my reply I had to spend (waste?) quite some time combining data from 3 different sources (oh - and we do have a DW here, it's just not comprehensive. So we've introduced a second one on a different platform - you couldn't make this up really)
It's "doable", especially with modern connectors and tools, but a real PITA - I seem to waste more time sourcing data to then be merged, than I do actually doing the analysis to gain insight. Like I said - frustrating.
Perhaps then that is your most compelling argument ... A DW makes it easier and quicker to bring real insight to the business, turn data into information, to drive down costs and raise profitability.
(I'm starting to sound like an advert so I will stop there )
|
|
|
|