Is it necessary to flash SailfishOS again If i buy used xperia?Or just purchase license and login in device?
No, if SFOS is installed on the device, you don’t have to flash again.
But if you want to print out a bill for the paid SFOS licence, you need the Jolla shop access data (username and password) from the seller of your phone. In this shop-account you can change the real name from the sellers name to your name and print an invoice with your name on it.
After this you can create your own Jolla account and enter the access data into the Jolla account settings of your used phone.
Maybe the Jolla shop app download will not work, then delete the old account on the phone (settings -> accounts), then create a new Jolla account on the phone and enter the access data of your own Jolla account.
you can reset the device, if prev owner did not
but no reflash is needed