Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.19 MySQL Community Server - GPL
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.03 sec)
kodingwindow@kw:~/csharp$
C# program to create a table in MySQL
Program.cs
usingMySql.Data.MySqlClient;usingSystem;namespaceKodingWindow{classProgram{publicstaticvoidMain(string[]args){MySqlConnectioncon=newMySqlConnection("server=localhost;database=DB;user=root;port=3306;password=passwd");MySqlCommandcmd;try{con.Open();cmd=newMySqlCommand("CREATE TABLE holders(account_no BIGINT PRIMARY KEY, name VARCHAR(30) NOT NULL, bank VARCHAR(10), amount BIGINT NOT NULL)",con);cmd.ExecuteNonQuery();Console.WriteLine("Table Created");Console.WriteLine("\nList of MySQL Tables: ");cmd=newMySqlCommand("SHOW TABLES",con);MySqlDataReaderdr=cmd.ExecuteReader();while(dr.Read()){Console.WriteLine(dr[0]);}dr.Close();con.Close();}catch(Exceptione){Console.WriteLine(e.Message);}Console.ReadKey();}}}
Output
Table Created
List of MySQL Tables:
holders
MySQL Instance
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| db |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> USE DB;
Database changed
mysql> SHOW TABLES;
+--------------+
| Tables_in_db |
+--------------+
| holders |
+--------------+
1 row in set (0.00 sec)
mysql> DESC holders;
+------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+-------+
| account_no | bigint | NO | PRI | NULL | |
| name | varchar(30) | NO | | NULL | |
| bank | varchar(10) | YES | | NULL | |
| amount | bigint | NO | | NULL | |
+------------+-------------+------+-----+---------+-------+
4 rows in set (0.33 sec)
kodingwindow@kw:~/csharp$
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the KodingWindow Android app. We intend to soon make it available on the Google Play Store. Currently, you need to install apk manually. Would you like to get the app? Minimum Requirement(s): Android 10