You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/01/04 05:40:27 UTC

[GitHub] [incubator-shardingsphere] Sunnycheey opened a new issue #3865: Create tables automatically by ddl

Sunnycheey opened a new issue #3865: Create tables automatically by ddl
URL: https://github.com/apache/incubator-shardingsphere/issues/3865
 
 
   ## Question
   
   **For English only**, other languages will not accept.
   
   Hello, I am a newbie in this field, so my questions maybe a little stupid to you... (But I indeed need some help)
   
   My question is, **how to create actual data node by sql script (ddl)**.
   
   When using tranditional JDBC-Driver, I can call script runner to do this task (by retrieve the only datasource). But in sharding-jdbc, there are many database (schema) in one instance (e.g, ds0, ds1, ...), I tried using autowire the datasource sharding-jdbc provide, and then using script runner to run ddl, but it seems it doesn't work.
   
   the ddl looks like this:
   
   ```sql
   DROP SCHEMA IF EXISTS USERS;
   CREATE SCHEMA USERS;
   SET SCHEMA USERS;
   DROP TABLE IF EXISTS USER0;
   DROP TABLE IF EXISTS USER1;
   CREATE TABLE USER0(
                         id bigint primary key not null,
                         username varchar(30) not null,
                         password char(64) not null,
                         email varchar(40) unique not null
   );
   =
   CREATE TABLE USER1(
                         id bigint primary key not null,
                         username varchar(30) not null,
                         password char(64) not null,
                         email varchar(40) unique not null
   );
   DROP SCHEMA IF EXISTS GOODS;
   CREATE SCHEMA GOODS;
   SET SCHEMA GOODS;
   DROP TABLE IF EXISTS goods;
   CREATE TABLE goods(
                         id bigint primary key,
                         user_id bigint not null,
                         name varchar(40) not null,
                         introduction varchar(100) not null,
                         picture_u_r_l char(40) default 'url',
                         kind char(40) default 'unknown',
                         original_price int,
                         current_price int not null,
                         amount int not null,
                         upload_time date not null
   );
   ```
   By the way, is there some convient way to create actual datanode in different database by only one schema, since I rewrite `user1` and `user2` in the above sql script.
   
   Appericate your wonderful work, and willing to accept rely....

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] taojintianxia edited a comment on issue #3865: Create tables automatically by ddl

Posted by GitBox <gi...@apache.org>.
taojintianxia edited a comment on issue #3865: Create tables automatically by ddl
URL: https://github.com/apache/incubator-shardingsphere/issues/3865#issuecomment-570899756
 
 
   hi @Sunnycheey 
   
   No stupid people in this community, only someone familiar or someone unfamiliar with it.
   
   there are a lot of examples for people to start with : [shardingsphere exmple](https://github.com/apache/incubator-shardingsphere-example/tree/dev/sharding-jdbc-example/sharding-example)
   
   And if I were you, I perfer to have a try for proxy, it's also convenient for DBA or devops :
   
   ### [proxy document](https://shardingsphere.apache.org/document/current/en/manual/sharding-proxy/)
   ### [proxy example](https://github.com/apache/incubator-shardingsphere-example/blob/dev/docker/docker-compose.md)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] terrymanu closed issue #3865: Create tables automatically by ddl

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #3865: Create tables automatically by ddl
URL: https://github.com/apache/incubator-shardingsphere/issues/3865
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] taojintianxia edited a comment on issue #3865: Create tables automatically by ddl

Posted by GitBox <gi...@apache.org>.
taojintianxia edited a comment on issue #3865: Create tables automatically by ddl
URL: https://github.com/apache/incubator-shardingsphere/issues/3865#issuecomment-570899756
 
 
   hi @Sunnycheey 
   
   No stupid people in this community, only someone familiar or someone unfamiliar with it.
   
   there are a lot of examples for people to start with : [shardingsphere exmple](https://github.com/apache/incubator-shardingsphere-example/tree/dev/sharding-jdbc-example/sharding-example)
   
   And if I were you, I perfer to have a try on proxy, it's also convenient for DBA or devops :
   
   ### [proxy document](https://shardingsphere.apache.org/document/current/en/manual/sharding-proxy/)
   ### [proxy example](https://github.com/apache/incubator-shardingsphere-example/blob/dev/docker/docker-compose.md)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] terrymanu commented on issue #3865: Create tables automatically by ddl

Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #3865: Create tables automatically by ddl
URL: https://github.com/apache/incubator-shardingsphere/issues/3865#issuecomment-571148664
 
 
   ShardingSphere can support DDL, you can try to create your table via logic table name.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] taojintianxia commented on issue #3865: Create tables automatically by ddl

Posted by GitBox <gi...@apache.org>.
taojintianxia commented on issue #3865: Create tables automatically by ddl
URL: https://github.com/apache/incubator-shardingsphere/issues/3865#issuecomment-570899756
 
 
   hi @Sunnycheey 
   
   there is no stupid people in this community, only someone familiar or someone unfamiliar with it.
   
   there are a lot of examples for people to start with : [shardingsphere exmple](https://github.com/apache/incubator-shardingsphere-example/tree/dev/sharding-jdbc-example/sharding-example)
   
   And if I were you, I perfer to have a try for proxy, it's also convenient for DBA or devops :
   
   ### [proxy document](https://shardingsphere.apache.org/document/current/en/manual/sharding-proxy/)
   ### [proxy example](https://github.com/apache/incubator-shardingsphere-example/blob/dev/docker/docker-compose.md)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Sunnycheey opened a new issue #3865: Create tables automatically by ddl

Posted by GitBox <gi...@apache.org>.
Sunnycheey opened a new issue #3865: Create tables automatically by ddl
URL: https://github.com/apache/incubator-shardingsphere/issues/3865
 
 
   ## Question
   
   **For English only**, other languages will not accept.
   
   Hello, I am a newbie in this field, so my questions maybe a little stupid to you... (But I indeed need some help)
   
   My question is, **how to create actual data node by sql script (ddl)**.
   
   When using tranditional JDBC-Driver, I can call script runner to do this task (by retrieve the only datasource). But in sharding-jdbc, there are many database (schema) in one instance (e.g, ds0, ds1, ...), I tried using the autowired datasource sharding-jdbc provide, and then using script runner to run ddl, but it seems it doesn't work.
   
   the ddl looks like this:
   
   ```sql
   DROP SCHEMA IF EXISTS USERS;
   CREATE SCHEMA USERS;
   SET SCHEMA USERS;
   DROP TABLE IF EXISTS USER0;
   DROP TABLE IF EXISTS USER1;
   CREATE TABLE USER0(
                         id bigint primary key not null,
                         username varchar(30) not null,
                         password char(64) not null,
                         email varchar(40) unique not null
   );
   =
   CREATE TABLE USER1(
                         id bigint primary key not null,
                         username varchar(30) not null,
                         password char(64) not null,
                         email varchar(40) unique not null
   );
   DROP SCHEMA IF EXISTS GOODS;
   CREATE SCHEMA GOODS;
   SET SCHEMA GOODS;
   DROP TABLE IF EXISTS goods;
   CREATE TABLE goods(
                         id bigint primary key,
                         user_id bigint not null,
                         name varchar(40) not null,
                         introduction varchar(100) not null,
                         picture_u_r_l char(40) default 'url',
                         kind char(40) default 'unknown',
                         original_price int,
                         current_price int not null,
                         amount int not null,
                         upload_time date not null
   );
   ```
   By the way, is there some convient way to create actual datanode in different database by only one schema, since I rewrite `user1` and `user2` in the above sql script.
   
   Appericate your wonderful work, and willing to accept rely....

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] terrymanu closed issue #3865: Create tables automatically by ddl

Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #3865: Create tables automatically by ddl
URL: https://github.com/apache/incubator-shardingsphere/issues/3865
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] kimmking commented on issue #3865: Create tables automatically by ddl

Posted by GitBox <gi...@apache.org>.
kimmking commented on issue #3865: Create tables automatically by ddl
URL: https://github.com/apache/incubator-shardingsphere/issues/3865#issuecomment-570805343
 
 
   I think we can use a shell script to achieve it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [incubator-shardingsphere] Sunnycheey commented on issue #3865: Create tables automatically by ddl

Posted by GitBox <gi...@apache.org>.
Sunnycheey commented on issue #3865: Create tables automatically by ddl
URL: https://github.com/apache/incubator-shardingsphere/issues/3865#issuecomment-571547431
 
 
   Thanks for your all, and thanks for the suggesstion of @taojintianxia , I am going to try sharding-proxy. 
   
   Feel free to close the issue.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services