How can I make tables in MySQL? - mysql

I have two distinct scenarios.
One, where there is a many to many case, you must create a third table. But I'm not familiar with MySQL syntaxis.
Two, is this one:
How can I declare using SQL code?

In MYSQL my create tables using the CREATE TABLE command. If you don't feel too confident to write your tables with that syntax, I'd suggest using a tool like the MySQL Workbench. That tool can greatly help you there.

You need to have a look at CREATE TABLE Syntax

Related

Is there any way join tables of MySql and PostgreSQL?

I have a table in MySql in one server and a table in PostgreSQL in another server.
I want use use JOIN operation with those tables.
Is there any way to join the columns?
If not, is there any way to print the rows in same order?
Please help!!
Use mysql_fdw to define the MySQL table as a foreign table in PostgreSQL. Then you can join it with the PostgreSQL table in PostgreSQL.
You can use Materialize to achieve this.
Here is a sample demo project that you can run to see this in action:
You can find the code for the demo project and how to run it on GitHub here:
https://github.com/bobbyiliev/materialize-tutorials/tree/main/mz-join-mysql-and-postgresql
Hope this reference helps.
Yes, it is possible to work with multiple databases at the same time but you're looking in the wrong place. psycopg2 is just a library that simplifies accessing and manipulating data coming out of PostgreSQL but it doesn't go far beyond what you can do with psql. What you're looking to do you can solve on the database level by using Foreign Data Wrappers.
This does become more complicated in your schema definition but brings remote tables from host some.other.server database remote_db to appear as though they live on localhost in database local_db....
More:
https://dba.stackexchange.com/a/120682/197899

mysql 'show create table' on several tables

I have to get the SHOW CREATE TABLE tblName output of all the tables and write it to files (one file for each table).
Anyone can help me how I can begin to this? I suppose stored procedures? I am pretty sure that there is a tutorial I can follow because MySQL has a big community..
Thanks in advance
Some pictures of the output I need of each table:
Since your screenshot shows that you're using Windows; you can use HeidiSQL for your task.
There's an option in tools, titled Export database as SQL.

insert into remote server table without ssis and dts

My requirement is to create a stored procedure that joins two tables and inserts it into a remote server table.
How can I solve this without using ssis and any import/export data?
please
use the search before asking your question
Be more specific, stackoverflow is not here to write your whole program, people assist you
Use punctations marks and have a look at your format
Your question
Have a look at this, it shows you how to do that. You can first add a linked server(thats the destionation in your case) and then use it for your insert statement.

Retrieve Comments from tables and columns in a Mysql database

i have to build an application to manage an existing MySQL database. This database was created with MySQLworkbench and some useful comments were added to its tables and columns.
I think it would be great to somehow, query that comments and show them to the user to explain "what that field is". The problem is i don't know if its possible to retrieve that comments (they are only visible from the workbench).
EDIT:
in the MySQL existing database i have to work with there is no INFORMATION_SCHEMA table. I think is something usual to find it but in my model there is no :S
Try with:
SELECT column_comment FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='table_name';
You can parse the output of
show create table `YOURTABLE`;

Is it possible to use Linq to ALTER a database table?

I am trying to programmatically drop a column in a table inside of an access database and found myself unable to do so! Is it at all possible? it makes me think that i don't have any clear idea of things linq to sql can't do.
Any ideas?
There's nothing in LINQ to SQL that allows you to do that without writing T-SQL, no.
Similarly, you can't do straight updates or deletes without selecting the data you want to alter first and manipulating the objects. You'd have to write stored procedures for those things and add them to your model to be called. See this MSDN page for an overview.
Using DataContext.ExecuteQuery should also work if you don't mind T-SQL in your source code.
You can do it.
Here's an example:
ALTER TABLE Import
Alter column [Tot_Val] DECIMAL(10,2) ;
GO