In the context of trying to get someone’s real personal information from online/social media accounts, which is necessary?
A subpoena is a kind of court order. Specifically it is an order to a particular person to appear and testify at a particular time and place. In many but not all cases, the order also requires that person to bring specified records or documents along. That is known as a subpoena duces tecum. In some cases this is used to, order the production of documents without any accompanying testimony.
The word "subpoena" comes from Latin words meaning "under penalty" because the order requires the person to comply under penalty of being held in contempt of court and fined or imprisoned.
Ther are many other court orders, such as an injunction which is generally an order not to do something. Different jurisdictions may use different terms for orders with similar effects. The exact name and exact effect of a given order will vary with the jurisdiction, which is not stated in the question at the moment. The needed process to obtain a court order will also vary. Without a jurisdiction, a more specific answer cannot be given.
It is not unlikely that a subpoena of some sort will be the answer, but the details will depend on the jurisdiction, and on the reason why the information is being sought. It is likely that a lawyer will need to be consulted on the best way to obtain such an order.
If the issue is the same one as in this question or this question it is very unlikely that any court order would be sought for the person's information. If one were sought the details would depend on the asker's jurisdiction, which is not stated there as far as I can see.
A subpoena is a kind of court order, specifically one requiring the recipient to provide information to the court. A subpoena can be an appropriate order for a company to provide information to the court about one of its users. For example, Watchtower Bible and Tract Society filed a subpoena to compel Reddit to turn over information related to one of its users that was accused of violating Watch Tower's copyright.
A subpoena is usually issued in the context of a court case, although, in many states, particularly those that do not routinely use grand juries in all felony cases, prosecuting attorneys and certain state regulatory agencies also have subpoena power (as does Congress, at the federal level).
Unlike a court order, which must be approved by a judge, a subpoena can be issued by a party to a court case without advanced judicial approval. In most jurisdictions, a pro se party (i.e. a party not represented by a lawyer) can request that the clerk of the court issue a subpoena without judicial approval in advance, and a lawyer can issue a subpoena without the involvement of any court official simply by writing and having it delivered in the legally required manner (called "service").
Usually, however, in lawsuits were the person from whom the information is sought is a party to the lawsuit, a subpoena is not available to obtain information from the other party. Instead, a system of mandatory disclosures and "discovery" applies. There are somethings that the other party has to disclose without being asked (in some jurisdictions, whether or not the disclosing person plans to use them in the case, and in other jurisdictions, if the disclosing person wants to be allowed to use the documents in the case). But "discovery" usually consists of a combination of "requests for production" (mostly for paper and electronic documents), "interrogatories" (questions that must be answered in writing under oath by a set date with the assistance of the responding party's lawyer), "requests to admit" (setting forth facts that the responding party must admit or deny and explain the basis for the denial of), and "depositions" (a non-courtroom real time questioning of a witness under oath before a court reporter).
All of these means of getting information are mandatory.
The other side must object to and comply with either a subpoena or discovery request by the deadline set forth in court rules which is usually stated on the face of the document. An objection to a subpoena is often called a "motion to quash" the subpoena or a "motion for a protective order". When someone objects to a discovery request, they file an objection to the parts to the request to which they object by the deadline for responding. Typical objections include a privilege (such as attorney-client privilege), protection of a trade secret, or that the request is unduly burdensome on the party asked to comply with it.
At the point that there is either an objection, or simple non-compliance without a formal objection being made, to a subpoena or discovery, the party seeking the information then goes to the judge with a motion seeking to compel a response and/or sanction the non-compliant party.
If the judge agrees with the party seeking the information, then the judge issues a court order compelling a response by a date certain and/or sanctioning the non-compliant party with a monetary sanction, an adverse determination against a party in a case, or in the case of a third-party who has not responded to a subpoena, with a warrant for their arrest until such time as they comply or simply for defying the court for a misdemeanor-like sentence which cannot be purged by compliance.
You could also bring a court case seeking information only. In a case like that, the court could compel disclosure with a court order resolving that case on the merits by ordering that some or all of the information sought be provided.
Any lawsuit of this kind, needs to assert a legal basis for relief from the company. The substance of the law governing when a company is obligated to provide personal information to someone requesting it, however, is beyond the scope of the question. If it isn't alleged that the online information controlling party has done anything wrong, it would typically assert some kind of property right in the information, which would have to be determined on a case by case basis. Companies aren't always obligated to share personal information about users that they have collected.