Apologies if I am mistaken, but is there any way to create a table inside a column in MySql?
Brief: I have a table named test_table
which contains a column named name test_column
. Now I want to create a table inside test_column
. Is this possible?
Thanks In advance
You would create a "child" table with an id that is referenced in the column of the main table. You wouldn't create a "table" in a column.
For example
Table 1
columm_pk int
column_fk int
table 2
column_pk (this is what goes in table 1)
other columns as needed.
then you just join the tables based on that fk id. You can have multiple fk column in the first table that link to different child tables. You can also look in to SET data types in MySql although I wouldn't recommend them.
btw, If your question is MySql specific then you shouldn't use the oracle tags.
No nested tables in MySql, but there is a SET datatype that you can use in a table
http://dev.mysql.com/doc/refman/5.0/en/set.html
That approach is not possible. What you are looking for is a second table that is linked using a field in the first table.
Example:
test_table:
ID | column1 | some more columns
test_table2:
table1_ID | column1| column2...
You can then access them using JOIN
commands. For example:
SELECT *
FROM test_table t1
INNER JOIN test_table2 t2
ON t1.ID = t2.table1_ID
This way you can have multiple rows for each ID in table 1, which has the effect you are looking for.
This is not possible in MySQL.