MySQL Forums
Forum List  »  Newbie

Re: creating a table is there another way to do this?
Posted by: Barry Galbraith
Date: September 21, 2022 07:48PM

I created a text file called create.sql in my Documents folder
the file contains this
use test
CREATE TABLE mytesttable (
  id int unsigned NOT NULL AUTO_INCREMENT,
  test_date timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ;

From a windows command line prompt, you invoke mysql command line, directing it to read infrom a text file.

C:\Users\Barry>mysql -uroot -p < "D:/users/barry/documents/create.sql"
Enter password: ********


Then open a mysql command line to check the results of your work

C:\Users\Barry>mysql -uroot -p
Enter password: ********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 284
Server version: 8.0.27 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use test
Database changed
mysql> show tables;
| Tables_in_test |
| mytesttable    |
2 rows in set (0.02 sec)


Good luck,

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.