Dividir contenido de una columna en dos o mas en PostgreSQL

Hoy me encontré con una tabla persona con los datos apellidos en un solo campo por lo que opte por buscar la forma mediante sql de obtener por separado cada apellido en una columna distinta (apellido paterno, apellido materno).

Luego de unos minutos de realizar algunas búsquedas la solución fue la siguiente:

SELECT pers_apellidos,split_part(pers_apellidos,' ',1) AS apellido_paterno, split_part(pers_apellidos,' ',2) AS apellido_materno FROM persona

La solución fue utilizar una función que separa cadenas según un delimitador:

split_part()

SINTAXIS

split_part(string,delimiter,field)

string: la cadena que queremos separar delimiter: el delimitador field: la posición de texto que queremos mantener

quedando:

split-posgresql.png

listo!!! ahora su respectivo UPDATE.

Comentarios

1. El Lunes, Febrero 5 2018, 14:04 por Samuel (Buenos Aires)

Buenisimo me re sirvio. Muchas gracias!

2. El Lunes, Febrero 19 2018, 19:24 por Tania

Genial! fue de mucha ayuda, muchas gracias! :)

3. El Jueves, Octubre 4 2018, 03:30 por minecraft

I pay a quick visit everyday some blogs and information sites to read articles, except
this webpage gives feature based content.

4. El Viernes, Octubre 5 2018, 02:47 por minecraft

This is a topic that is close to my heart... Best wishes!
Where are your contact details though?

5. El Sábado, Octubre 6 2018, 07:52 por minecraft

Ahaa, its nice discussion concerning this piece of writing
at this place at this webpage, I have read all that, so at this time
me also commenting here.

6. El Sábado, Octubre 6 2018, 20:51 por minecraft

I am extremely impressed along with your writing talents and also with the format
in your blog. Is this a paid theme or did you modify it yourself?

Either way stay up the excellent quality writing, it is rare
to peer a nice blog like this one nowadays..

7. El Domingo, Octubre 7 2018, 00:44 por minecraft

Every weekend i used to go to see this website,
for the reason that i want enjoyment, since this this web site conations actually fastidious funny stuff
too.

8. El Domingo, Octubre 7 2018, 07:56 por minecraft

What's Taking place i am new to this, I stumbled upon this I've found It absolutely useful and it has helped me out loads.
I am hoping to give a contribution & assist different customers like its helped me.
Good job.

9. El Domingo, Octubre 7 2018, 17:11 por minecraft

Very quickly this website will be famous amid
all blogging viewers, due to it's pleasant posts

10. El Domingo, Octubre 7 2018, 21:30 por minecraft

Amazing! Its genuinely amazing piece of writing,
I have got much clear idea concerning from this
article.

11. El Lunes, Octubre 8 2018, 09:39 por minecraft free download 2018

You're so interesting! I do not think I've truly read anything like this before.

So nice to find someone with genuine thoughts on this topic.
Seriously.. thank you for starting this up. This web site is something that's needed on the
web, someone with a little originality!

12. El Lunes, Octubre 8 2018, 10:30 por minecraft free download 2018

Whoa! This blog looks just like my old one! It's on a completely different subject but
it has pretty much the same layout and design. Wonderful choice of colors!

13. El Lunes, Octubre 8 2018, 13:01 por minecraft free download 2018

Do you mind if I quote a couple of your articles as long as I provide credit and sources back
to your site? My website is in the very same niche as
yours and my visitors would genuinely benefit from a lot of the information you provide here.
Please let me know if this ok with you. Thanks a lot!

14. El Lunes, Octubre 8 2018, 13:04 por minecraft free download 2018

I am extremely inspired together with your writing talents and
also with the format for your blog. Is this a
paid topic or did you customize it your self?
Anyway keep up the excellent high quality writing, it's uncommon to peer a nice blog like this one today..

15. El Lunes, Octubre 8 2018, 22:01 por minecraft free download 2018

Thanks for the marvelous posting! I genuinely enjoyed reading it, you might be a great author.I
will remember to bookmark your blog and will eventually come back later in life.

I want to encourage continue your great posts,
have a nice day!

16. El Martes, Octubre 9 2018, 12:57 por minecraft free download 2018

I have been exploring for a little bit for any high-quality articles or weblog posts on this sort of
house . Exploring in Yahoo I ultimately stumbled upon this website.
Reading this info So i'm satisfied to express that I've an incredibly just right uncanny feeling I discovered just what I needed.
I so much surely will make certain to don?t omit this web site and provides it a
glance on a relentless basis.

17. El Martes, Octubre 9 2018, 13:41 por minecraft free download 2018

Please let me know if you're looking for a article author for your site.
You have some really good articles and I feel I would be a good asset.
If you ever want to take some of the load off, I'd absolutely love to write some articles for your blog in exchange for a link back to
mine. Please blast me an e-mail if interested. Regards!

18. El Martes, Octubre 9 2018, 15:44 por minecraft free download 2018

Hello it's me, I am also visiting this site on a regular
basis, this site is genuinely pleasant and the viewers are really sharing good
thoughts.

19. El Martes, Octubre 9 2018, 18:24 por minecraft free download 2018

With havin so much content do you ever run into any problems of plagorism or
copyright violation? My site has a lot of exclusive content I've either created myself or
outsourced but it looks like a lot of it is popping it up all over the
internet without my permission. Do you know any ways to help prevent content from
being ripped off? I'd truly appreciate it.

20. El Miércoles, Octubre 10 2018, 01:13 por minecraft free download 2018

I've read several just right stuff here. Certainly
value bookmarking for revisiting. I wonder how much attempt you place to make the sort of excellent
informative web site.

21. El Jueves, Octubre 11 2018, 05:29 por minecraft free download 2018

Its such as you learn my mind! You seem to grasp a lot approximately this, such as
you wrote the e book in it or something. I believe that you
can do with some percent to drive the message home a bit,
however instead of that, this is fantastic blog.
A great read. I will definitely be back.

22. El Jueves, Octubre 11 2018, 07:28 por minecraft free download 2018

Amazing! This blog looks exactly like my old one! It's on a entirely different subject but
it has pretty much the same layout and design. Excellent choice of colors!

23. El Miércoles, Octubre 17 2018, 23:17 por tinder dating site

I'm truly enjoying the design and layout of your blog.
It's a very easy on the eyes which makes it much more pleasant for me to come
here and visit more often. Did you hire out a designer to create your theme?
Fantastic work!

24. El Jueves, Octubre 18 2018, 08:22 por minecraft secret free download

My brother recommended I might like this web site.
He was entirely right. This post truly made my day.
You cann't imagine simply how much time I had
spent for this info! Thanks!

25. El Jueves, Octubre 18 2018, 16:11 por minecraft secret free download

Hey I know this is off topic but I was wondering if you knew of any widgets I
could add to my blog that automatically tweet my newest twitter updates.

I've been looking for a plug-in like this for quite some time and was hoping maybe
you would have some experience with something like this.
Please let me know if you run into anything. I truly
enjoy reading your blog and I look forward to your new updates.

Añadir un comentario

El código HTML se muestra como texto y las direcciones web se transforman automáticamente.

Discusiones sobre el mismo tema

URL de retroenlace : http://creativapixel.com/blog/index.php?trackback/9

1504 reads