How do I add same name table in different databases? - php

I have two different databases and in one database, I have "tblcontacts" table and when we create same name table in another database, it shows me error.
#1050 - Table 'tblcontacts' already exists.
I want same name table in two different databases.
please help me to get this.

Related

Searching Multiple Tables in database

How to search multiple tables for a keyword regardless of which table or column it would be in?
I am looking for information relating to for example a name or phrase which maybe in one or multiple tables in any column.

How to make your own table migration of two different tables

I was wondering how I can make a table migration of two different tables.
Let me simply explain the question
So let us say we have database a and a database b.
In both databases we have a table called user.
The table of user#a is the develop table and the table user#b is the production table.
Good. Now we have in user#a the following columns: username, passwordand email.
In user#b we have the following columns: username, password, email and role.
Now I need to merge these two tables.
So it needs to make a new column (same as user#b) and store the data in the column.
I have no idea of how I can do this.
If someone can help me with giving me a start I would be pleased.
I don't know if you should be able writing some websoftware to simply merge 2 databases. Since I'm a webdeveloper I may want to do that. So if someone can start me up with some more information... thanks!

Can you make/insert tables inside every row in a table of a database in PHP/MySQL?

Is it possible? If yes, how?
I am using xampp for my database and I wanted to make a database with "students" table, only one column for the list of student IDs, and every student ID has another table inside. (I was considering making tables for every student ID so that it can be done directly but it seems that it PHP/MySQL does not allow integers as table name).
No, you cannot put tables inside a row in SQL. That's not compatible with the concept of a relational database. What you can do is provide a foreign key to another table where you can collect the data you need to link to your first table.
What you need is to have one table with all you want about the students, and add a field with their ID.
So, yo don't have to get the information from student #123 as
SELECT * FROM 123
but
SELECT * FROM students_table WHERE IdStudent = 123

Rename a table, if the table is already exists then replace the table

I want to rename some 100 of tables to another table name. So i have created a query dynamically as (MYSQL),
RENAME TABLE table1 TO table 2
Now i face a problem that in some cases table 2 is existing already. In this case i want to replace that table 2 with table 1 only and old existing table should not be there.
Please help me on this. I tried using dropping first and rename. But it may cause some problem if i run that script again which will drop the renamed table also.

MySQL foreign key to table list

Lately I have been doing some work with MySQL and have come across the need to store table names as a field in one of my tables (which is not ideal). Instead I would like to reference a list of tables that currently exist in the database as a foreign key. I have found that the information_schema database stores a list of these tables however I cannot reference them as a foreign key as they are Memory tables. Is there another way I can reference the list of tables in the database as a foreign key.
For those interested, the reason I need to store the table names is because I am developing a basic PHP framework that exposes each table in the database as a class.
How dynamic is the list of tables in your database? One option is to create your own table and (periodically) fill it with the table names from information_schema.

Categories