Sql command to add 100 lines with same text in a collumn
Hello
I have a table named "data" and a column inside named "site" and i want to add 100 entries with the same data "www.mysite.com" Inside "site" column to be like: www.mysite.com www.mysite.com www.mysite.com www.mysite.com www.mysite.com etc How can i do that? Thank you |
If this is in regards to one of the Structured Query Language (SQL) databases, then INSERT is what you are looking for. However, the details vary per database. More information is needed.
Please write which database you have, including version, and which distro is it running on, including version. |
MariaDB 10.3.21
Centos 7.7 Thank you |
Thanks. There are several ways to get that result.
What have you tried so far in regards to INSERT and a FOR or other loop there? Please show your formula so far so we can see what your approach is, where you are stuck, and what level of complexity you are thinking of. |
Didn't find anything specific :(
I just found this: Code:
INSERT INTO data (site) VALUES('www.mysite.com') |
It's not about finding, it's about learning and writing your own.
INSERT is only part of the solution. You still need a loop to count to 100. Either a FOR loop or a WHILE loop will do, though there are other methods which would work too. Try looking closely at the two links in the previous post. |
Quote:
|
Yes but isn't practical to run manually 100 times that command that's why i am looking for a way to do it automatically....
|
@OP: Has your table got a structure? You know, key-fields and descriptive fields, dependencies, indices, stuff like that?
(My guess is that you have an XY problem, and now your az Z or W) |
Quote:
Quote:
|
Would you mind listing each and every fields (and their types) in this table?
|
Quote:
What is the actual problem you're dealing with that will be solved by creating a hundred one-column database rows with the exact same value? Additionally, what is the output of these two commands: Code:
show create table `data` Code:
select * from `data` limit 0,10 |
Quote:
That's the story. Don't know what else is missing. Quote:
> Time: 0,003s CREATE TABLE `data` ( `data` varchar(255) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 Quote:
> Time: 0,001s Empty... |
Quote:
Code:
for i in {1..100} |
For anyone that has not used Mariadb just typing in <command> is like for any old timer the cartoon that has an equation on the left and right in in the middle the saying "and then a miracle happens"...
From a practical standpoint a database table with a single column that contains the same data is useless since there is no way to "address" a single row. I assume this is why NevemTeve asked the question. So what you trying to accomplish? |
All times are GMT -5. The time now is 02:53 PM. |