How to handle a column named table in database table [duplicate] - sql

This question already has answers here:
How to deal with SQL column names that look like SQL keywords?
(17 answers)
Syntax error due to using a reserved word as a table or column name in MySQL
(1 answer)
Are quotes around tables and columns in a MySQL query really necessary?
(4 answers)
Closed 2 years ago.
I am currently working with Joomla. I want to insert a new row into #__content_types table, but there is a column named table that is currently giving me errors.
How do I insert the data despite the name of the column 'table'?
INSERT INTO #__content_types(type_id, type_title, type_alias, table, field_mappings)
VALUES
('14','SVG Image','com_view_vv.form','{"special":{"dbtable":"#__table","key":"id","type": "Corecontent","prefix":"JTable","config":"array()"},"common":{"dbtable": "#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}', '{"common": {"core_content_item_id":"id","core_title":"name","core_alais": "alias"},"special":{"imptotal":"imptotal","impmade":"impmade","clicks": "clicks","clickurl": "clickurl","custombannercode":"custombannercode","cid":"cid","purchase_type": "purchase_type","track_impressions":"track_impressions","track_clicks":"track_clicks"}}');

Related

When do we use double quotes for table names in SQL? [duplicate]

This question already has answers here:
When do Postgres column or table names need quotes and when don't they?
(2 answers)
Are PostgreSQL column names case-sensitive?
(5 answers)
Closed 3 months ago.
A SQL coding challenge provided a database; every table was accessible when passed as a string using double quotes and not when passed as a word as I am normally used to.
This did not work:
SELECT * FROM Athletes;
Error message: relation does not exist.
But this worked and I don't understand why:
SELECT * FROM "Athletes";
Was this defined during the database creation? Or is this from PostgreSQL?

SQL require table name in values section [duplicate]

This question already has answers here:
postgres column "X" does not exist
(1 answer)
Postgres error updating column data
(2 answers)
PostgreSQL "column "foo" does not exist" where foo is the value
(1 answer)
Closed 2 years ago.
I am trying to store the data in table by using insert query (I am using PostreSQL), but there is it.
ERROR: column "Fleet" does not exist
LINE 1: insert into appuser values("Fleet")
Postresql require column name in values section, but what is that? Why? (There is only test, my 'appuser' table has 2 columns, one of it is primary key auto-generated, so do not get confuse)
Your table has two columns and you are providing a value for only one, so you need to tell the database which one it is. Also, literal strings must be surrounded with single quotes (double quotes stand for column identifiers).
Assuming that the target column is mycol, that would be:
insert into appuser (mycol) values('Fleet')

Automatically prefix columns with the same name in a select [duplicate]

This question already has answers here:
Prefix all columns in T-SQL statement
(3 answers)
Prefix every column name with a specific string?
(1 answer)
How can I prefix all column names in a T-SQL function?
(2 answers)
Closed 3 years ago.
How could one easily select from tables that contain columns with the same name? Conflicting names in a CTE for example are not allowed. Is there a way to for example automatically rename all of the columns as TableName_ColumnName? Having to write out all of the columns just for this is very impractical.

To see whether a column of a table is been used somewhere in the database [duplicate]

This question already has answers here:
How can we figure out that a column in my oracle table is being populated/updated by a trigger of another table?
(3 answers)
Closed 5 years ago.
How to check whether a particular column of a table is used in any other object or not in Oracle? For example I have a table EMPLOYEE which has a column BONUS. I need to check whether this column of this table is been used by any other objects like View, Package etc in the database.
You can try the following SQL to check for the table and column used within the object definition
SELECT 1
FROM all_source
WHERE type IN ('PROCEDURE','PACKAGE BODY','FUNCTION')
AND text LIKE '%EMPLOYEE%'
AND text LIKE '%BONUS%';

How do I search the name of a table, knowing only one of the table's column name in SQL? [duplicate]

This question already has answers here:
Search an Oracle database for tables with specific column names?
(4 answers)
Closed 7 years ago.
I'm trying to find a table containing a column that I know the name to. Is there some way to do a table search using only the name of the column?
In oracle
select * from user_tab_columns where column_name= '';