Sample Header Ad - 728x90

Database Administrators

Q&A for database professionals who wish to improve their database skills

Latest Questions

0 votes
2 answers
4060 views
How can i convert all object Ids to string using query in MongoDB, note the structure is complex, So can't use $toString in $addFields and $project?
I have a really deep-nested JSON object generated by aggregation query, but I want to convert all the object ids to string format. Tried $toString in $addFields and $project. Since the object is nested and contains an array of objects with object id. It's difficult to do using this. Is there any oth...
I have a really deep-nested JSON object generated by aggregation query, but I want to convert all the object ids to string format. Tried $toString in $addFields and $project. Since the object is nested and contains an array of objects with object id. It's difficult to do using this. Is there any other way by which I can convert all object ids to string in MongoDB during querying?
Manoj Selvin (101 rep)
Jul 27, 2021, 03:13 PM • Last activity: Feb 16, 2024, 07:06 AM
10 votes
3 answers
2115 views
Is it possible for master, tempdb, model and msdb to have a database_id other than 1,2,3,4 respectively?
SQL Server [System Databases](https://learn.microsoft.com/en-us/sql/relational-databases/databases/system-databases?view=sql-server-ver15), as far as I know, always have those same IDs and I have seen lots of maintenance scripts on the internet relying on the predicate `WHERE database_id > 4` to exc...
SQL Server [System Databases](https://learn.microsoft.com/en-us/sql/relational-databases/databases/system-databases?view=sql-server-ver15) , as far as I know, always have those same IDs and I have seen lots of maintenance scripts on the internet relying on the predicate WHERE database_id > 4 to exclude them from the actions of the script. Also, if I run SELECT name, schema_id FROM sys.schemas; on a new user database, I get: name schema_id dbo 1 guest 2 INFORMATION_SCHEMA 3 sys 4 db_owner 16384 db_accessadmin 16385 db_securityadmin 16386 db_ddladmin 16387 db_backupoperator 16389 db_datareader 16390 db_datawriter 16391 db_denydatareader 16392 db_denydatawriter 16393 I ran that query on two different instances, one a SQL Server 2016 and the other a SQL Server 2005, and both returned that same result. Questions: ---------- 1. Is there any situation (or sql server version) in which the system databases master, tempdb, model and msdb would have a database_id other than 1,2,3,4 respectively? 2. Can I **really** trust on the fact that the schemas I listed will always have the same IDs on any instance of SQL Server so that I can write maintenance scripts based on those IDs?
Ronaldo (6017 rep)
Feb 12, 2020, 12:25 PM • Last activity: Oct 14, 2022, 09:28 AM
5 votes
2 answers
8099 views
Unable to output data from tables in pgAdmin4 due to missing oid operator
I am currently running Postgresql 10.6 locally which I interface with using PgAdmin 4.12, up until today everything was running fine. However today I ran the following query in the pgAdmin query editor: SELECT * FROM test_table LIMIT 100 and got the following error: > ERROR: operator does not exist:...
I am currently running Postgresql 10.6 locally which I interface with using PgAdmin 4.12, up until today everything was running fine. However today I ran the following query in the pgAdmin query editor: SELECT * FROM test_table LIMIT 100 and got the following error: > ERROR: operator does not exist: - oid at character 125 > HINT: No operator matches the given name and argument type. You might need to add an explicit type cast. > STATEMENT: SELECT at.attname, at.attnum, ty.typname > FROM pg_attribute at LEFT JOIN pg_type ty ON (ty.oid = at.atttypid) > WHERE attrelid=-1519044407::oid AND attnum = ANY ( > (SELECT con.conkey FROM pg_class rel LEFT OUTER JOIN pg_constraint con ON con.conrelid=rel.oid > AND con.contype='p' WHERE rel.relkind IN ('r','s','t', 'p') AND rel.oid = -1519044407::oid)::oid[]) The strange thing is when I run the same command on tables which were created yesterday, the data is output into the Pgadmin data output window successfully. I also tried running the same command with psql: psql -U postgres -d geodata -c 'SELECT * FROM test_table LIMIT 100' which was also successful. I am able to create tables in Pgadmin just not output them directly. Any new table I create and then output ends with the top error, the only difference is the oid changes. I have uninstalled Pgadmin and made sure to delete all leftover folders and reinstalled with no change. Does anyone have any ideas what the problem is? Is the issue coming from pgadmin or is my Postgresql server corrupted in some way?
Trashmonk (153 rep)
Sep 6, 2019, 01:57 AM • Last activity: Nov 11, 2019, 08:13 AM
1 votes
1 answers
1684 views
Is there a way to store int in ObjectID?
I'm trying to migrate MySQL user ids to MongoDB. user ids are incremental values like 1,2,3,4... Is there a way to store int in `ObjectID`?
I'm trying to migrate MySQL user ids to MongoDB. user ids are incremental values like 1,2,3,4... Is there a way to store int in ObjectID?
Alireza (3676 rep)
Mar 5, 2019, 03:00 PM • Last activity: Mar 8, 2019, 03:45 PM
Showing page 1 of 4 total questions