Is it possible with DataGrip to add a row containing a foreign key and navigate to referenced table to select it? - datagrip

In some database client (e.g. postico), when you add a new row using the GUI, it's still possible to search and select the id of the referenced table.
I'm using DataGrip and I could not find an equivalent. I've been through the documentation and could not find anything. Did I search correctly?

It's actually on the issue tracker:
https://youtrack.jetbrains.com/issue/DBE-1912

Related

Can't create new columns, constraints, indexes using DBeaver 7 in MySQL 8

I'm attempting to create new tables and add new columns to an existing MySQL 8 database. I'd like to use DBeaver GUI for this task. Creating the new connection with the MySQL 8+ driver, I'm able to connect to my localhost using root user.
I'm able to load the database tables and explore their columns, constraints, properties, etc. But I'm not able to create new columns... I can't see any option similar to New column, New Table, etc. In MySQL Workbench, for example, one just has to right-click over the grid to be able to add new columns.
I've right-clicked everywhere and I've read all menus and I'm not able to find a way to insert something new using the GUI. It seems as if I was in a read-only connection. However, I didn't check Security: Read-only connection when creating the connection (double checked).
Under table properties, if I right-click and I select Generate SQL > INSERT I'm not able to type anything in the resulting window...
Testing my connection I got the following:
Connected (30 ms)
Server:
MySQL 8.0.21
Driver:
MySQL Connector/J mysql-connector-java-8.0.17 (Revision: 16a712ddb3f826a1933ab42b0039f7fb9eebc6ec)
Finally, in table properties, if I change the table description, click de Save button and then the Persist button, I'm able to update the description. What am I doing wrong then?
I'm missing something obvious for sure.
Thanks in advance.
You can make changes to your tables with SQL. Click on the 'New SQL Editor' button here:
Then type up your SQL:
ALTER TABLE db_name.my_table,
ADD COLUMN column_1 NULL,
ADD COLUMN column_2 TEXT,
ADD COLUMN first_name VARCHAR(255);
Make sure you check the syntax for your specific version of MySql, and when you've got what you want there, click the 'Execute SQL Script' button:
That should do the trick.
Checked on windows machine on DBeaver 21.3.2, right the respective table on which you want to add column, click on "create column" and then enter the name and default values of the column like Auto increment and not null etc.
Finally click save and persist those changes in the database if you are sure of the changes you did otherwise edit the column and then persist them.
Running on Linux but seeing the same issue. I was able to start adding columns in the left pane, in the Database Navigator. Open a table, then right mouse on a table and you will see the option to add a column. Thereafter you can add columns in the properties tab.

dbeaver table editing is blocked, what should I do?

image
You cannot edit the data in the table.
Field names are marked as locked.
How do I solve this?
DB : ORACLE
try to refresh the database connection. It worked for me, I couldn't insert rows after creating the table.
Never used dbeaver myself... after a little googling found this forum
post: https://dbeaver.io/forum/viewtopic.php?f=2&t=621
Though, this is an old post it mentions that:
DBeaver can edit table only if it has at least one unique key or index
and also
regarding oracle pseudo columns like rowid
for now DBeaver doesn't support "hidden" pseudocolumn at all
So, could you check if you can edit tables with unique key?

Importing csv using Datagrip (table with identity column)

How to import CSV file into SQL Server table with identity column using DataGrip.
More precisely, how to exclude the identity column during the import or force importing the identity column?
Assume, you've got a table
create table test_identity_insert(

 x bigint primary key identity(1,1),
y int
);
go
You need to change data mappings
From the 'Import: "file_Name.csv" Format' window, on the Columns tab, click the trash can icon with the Identity column highlighted. (See screencap here, I don't currently have the reputation allowed to insert images.)
Also, see the bottom of the 'Import: Format Dialog' help page in DataGrip, or the web help here.

Oracle SQL Developer - using foreign keys

First of, this is a pretty basic question but I cant seem to find a basic tutorial on how to use the software.
If i have a table named COUNTRY with the field region_id
and then another table named REGION with a primary key as region_id.
I want to set the region_id field in COUNTRY table as a foreign key.
Are the following steps correct?
Go to constraints, add a new foreign key.
Select COUNTRY as table
Change local column to region_id
![enter image description here][1]
Am I doing it correctly? if not, where am i going wrong
Yes, This is the correct procedure.
If you want your foreign key to have additional behavior (e.g., ON DELETE CASCADE), you can use the "on delete" drop-down in the wizard.
I cant seem to find a basic tutorial on how to use the software.
Have you looked at the Oracle Learning Library for SQL Developer tutorials?
If you search for: Getting Started with Oracle SQL Developer 4.0 you will find a tutorial that gets you up and running SQL Developer, this tutorial includes how to create Foreign Key Constraints.

Enforcement of unique/primary key - drop index

I am trying to drop an index :
DROP INDEX PK_CHARGES
but I get this error
cannot drop index used for enforcement of unique/primary key
Why I am getting this error? I will provide further information if you need any.
How to solve it?
Edit I have no primary key in the table, but I found this weird index that I don't remember I had added:
index name = SYS_C0040476 which have the same columns
You can query the ALL_CONSTRAINTS performance view to see which constraint the index is used by, and which table it applies to, e.g:
select owner, constraint_name, constraint_type,
table_name, index_owner, index_name
from all_constraints
where index_name = 'PK_CHARGES';
I would expect the table name to be 'CHARGES', the constraint name to match the index name, and the constraint type to be 'P'. But since you have a table in mind, perhaps the names aren't following a helpful convention. Maybe an old version of the table was renamed, which would leave the constraints against the new name (e.g. CHARGES_BACKUP or something).
You said you click on the table, then on the view. Perhaps you're not looking at the table that the constraint/index is on; or perhaps you're looking at a view on top of the actual table. You also mention a SYS_ index on the same columns - which can't be on the same table. Do you have multiple similar tables, or access to multiple schemas? You shold run the above query for that index too. As mentions above, you might find an old version (or versions) of the table.
Once you've identified which table the constraint is on, you'll need to decide whether you should actually be keeping it, and if not you can remove it by dropping the constraint with an ALTER TABLE command.
The problem with
But I found this weird index that I dont rember I hadve add
comes because you didn't add it. You had a primary key, then you dropped it, but when you do that Oracle doesn't drop the associated unique index that every primary key has.
So when you drop a primary key you have to drop the unique index of that primary key, that amazingly has the same name as the primary key had.
So for dropping a MY_TABLE_PK you must do:
ALTER TABLE MY_TABLE DROP PRIMARY KEY DROP INDEX;
so you ensure that the index is dropped as well.
"from pl/sql I right click on the table"
The problem with IDEs is that they make us feel very productive, because we can do things with just a click instead of writing some code. This is a problem because when something unusual happens the IDE is no good for investigation and we lack the understanding of the underlying structure of the database which we need to help ourselves.
If you want to learn the Oracle database the worst thing you can do is download SQL Developer or PLSQL Developer or TOAD. They're all fine tools but the only people who should use them are the people who don't need to use them.
the following worked for me with unique index:
ALTER INDEX UX_CHARGES UNUSABLE
/
DROP INDEX UX_CHARGES
/
see: https://docs.oracle.com/cd/E18283_01/server.112/e17120/indexes004.htm#insertedID3

Resources