2 Samuel 22:1 David sang to the Lord the words of this song when the Lord delivered him from the hand of all his enemies and from the hand of Saul. 2 He said:

“The Lord is my rock, my fortress and my deliverer;
3 my God is my rock, in whom I take refuge,
my shield[a] and the horn(b) of my salvation.
He is my stronghold, my refuge and my savior—
from violent people you save me.

a. 2 Samuel 22:3 Or sovereign
b. 2 Samuel 22:3 Horn here symbolizes strength.

Apparently I'll see this "song" again in Psalms. Apparently it's nearly identical to Psalms 18.

I use to work down near McPhearson Square. I'm an early riser so the city was in transition when I was walking through the square in the mornings. The hookers were generally gone, but the homeless were still in their "tents". Sometimes there were some people still mulling around the park looking for something to get into. At times it could be a little tense.... but then I would "feel" [imagine I guess] an arm across both my shoulders.... like a big old bestest buddy slung his arm around me to protect me. Oh it got better if any strangers came too close. It was then that I could "hear" [imagine I guess] a shotgun being loaded and steadied to take on all comers. I never needed to "feel" or "hear" for real. I was never approached.

This is from Bible.org.

In the first verse of the psalm, we are given the historical background for this song of David. This psalm was written by David after God delivered him from the hand of his enemies and from the hand of Saul. It would seem then that the psalm was written shortly after Saul's death and at the outset of David's reign as king. David now occupies the throne, and from this vantage point, he reflects on God's gracious dealings in his life to fulfill His promise that he would be Israel's king.

The actual psalm begins with David's praise to God for who He is -- his refuge. Employing a handful of symbols, David speaks of God as his place of safety. He is David's rock (or lofty crag, v. 2). No doubt David had spent much of his time standing upon such crags, looking down from the lofty heights, knowing that he was virtually inaccessible to his enemies. God is David's “fortress” and his “stronghold.” He is David's “shield,” and the “horn of his salvation.” These are not mere images; these are the very means God employed to save David's life from the hand of his enemies. And now, David urges us to look behind these means which God employed to God Himself. It is God who delivers; it is He who is our protector and deliverer. He is our place of safety.

This is from studylight.org.

This entire chapter is a duplicate of Psalms 18, with only the slightest variations, none of which is of any special importance. However, these variations, inconsequential as they are, have been the basis of some comments which might not necessarily be true. For example, our greatly respected Dr. Willis, whose work in the Books of Samuel have been so helpful in these studies, pointed out that, "Whole lines may appear in one of these chapters but not in the other, words or phrases may appear in one but not in the other, synonyms of some words may be used in one of these in place of a different word in the other; and some words are transposed, appearing in a different order in one as compared with the other."

All of this, of course, is certainly true, but what should be our conclusion from the consideration of such facts? Willis concluded that, "This shows that the Biblical authors were not concerned with preserving the exact words of those whom they quoted." To this usual deduction, echoed by many scholars, we wish to oppose an opposite view which this writer has long accepted, namely, that both chapters, even with their variations, are inspired and true exactly as they stand. It is certainly possible that David repeated this Psalm with the identical variations which appear in them.

I use to watch American Idol. Those judges always wanted the singer to "make the song yours". Since most of these commentaries were written by stodgy old men who wouldn't watch anything as frivolous as American Idol anyway. They would rather fight about the authenticity of the song rather than realizing.... David is a musician.... and maybe he was just making his own song his by changing the beat, tone, or a word or two in the second show!